Skip to content

Commit c487f9d

Browse files
committed
Move aggregate initialization to own file
1 parent ca28aab commit c487f9d

File tree

2 files changed

+164
-155
lines changed

2 files changed

+164
-155
lines changed

cpp23/aggregate_init.dot.cpp

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#ifndef AGGREGATE_INIT_INCLUDED
2+
#define AGGREGATE_INIT_INCLUDED
3+
4+
#include "common.h"
5+
6+
#define AGGREGATE_INIT_HEAD aggregate_initialization_head
7+
8+
// [dcl.init.aggr]
9+
subgraph cluster_aggregate_initialization {
10+
// 2
11+
{
12+
INSTRUCTION_NODE(AGGREGATE_INIT_HEAD, "Aggregate initialization", "[dcl.init.aggr]")
13+
-> INSTRUCTION_NODE(aggregate_determine_elements, "Determine the elements of the aggregate.", "[dcl.init.aggr]/2")
14+
-> aggregate_elements_type
15+
16+
QUESTION_NODE(aggregate_elements_type, "What is the type of the aggregate?", "[dcl.init.aggr]/2")
17+
aggregate_elements_type -> aggregate_elements_array [label="an array type"]
18+
aggregate_elements_type -> aggregate_elements_class [label="a class type"]
19+
20+
INSTRUCTION_NODE(aggregate_elements_array, "The elements are the array elements in increasing subscript order.", "[dcl.init.aggr]/2.1")
21+
aggregate_elements_array -> aggregate_determine_explicit_init_elems
22+
23+
INSTRUCTION_NODE(aggregate_elements_class, "The elements are the direct base classes in declaration order, followed by the direct non-static data members that are not members of an anonymous union, in declaration order.", "[dcl.init.aggr]/2.2")
24+
aggregate_elements_class -> aggregate_determine_explicit_init_elems
25+
}
26+
27+
// 3
28+
{
29+
INSTRUCTION_NODE(aggregate_determine_explicit_init_elems, "Determine the explicitly initialized elements", "[dcl.init.aggr]/3")
30+
-> aggregate_explicit_is_designated
31+
32+
// 3.1
33+
{
34+
YN_QUESTION_NODE(aggregate_explicit_is_designated, "Is the initializer list a brace-enclosed designated-initializer-list?", "[dcl.init.aggr]/3.1", aggregate_explicit_desginated_is_class, aggregate_explicit_is_init_list)
35+
36+
YN_QUESTION_NODE(aggregate_explicit_desginated_is_class, "Is the aggregate of class type?", "[dcl.init.aggr]/3.1", aggregate_explicit_designated_are_designators_valid, NEW_ILL_FORMED())
37+
YN_QUESTION_NODE(aggregate_explicit_designated_are_designators_valid, "Does each designator's identifier name a direct non-static data member of that class?", "[dcl.init.aggr]/3.1", aggregate_explicit_desginated, NEW_ILL_FORMED())
38+
39+
INSTRUCTION_NODE(aggregate_explicit_desginated, "The explicitly initialized elements are those named by the designator's initializers (or those that contain the named elements).", "[dcl.init.aggr]/3.1")
40+
-> aggregate_explicit_is_union
41+
}
42+
43+
// 3.2
44+
{
45+
YN_QUESTION_NODE(aggregate_explicit_is_init_list, "Is the initializer list an brace-enclosed initializer-list?", "[dcl.init.aggr]/3.2", aggregate_explicit_init_list_defn_n, aggregate_explicit_empty)
46+
47+
INSTRUCTION_NODE(aggregate_explicit_init_list_defn_n, "Let n be the number of elements in the initializer list.", "[dcl.init.aggr]/3.2")
48+
-> INSTRUCTION_NODE(aggregate_explicit_init_list, "The explicitly initialized elements are the first n elements of the aggregate.", "[dcl.init.aggr]/3.2")
49+
-> aggregate_explicit_is_union
50+
}
51+
52+
// 3.3
53+
{
54+
INSTRUCTION_NODE(aggregate_explicit_empty, "The initializer list is \"{}\", and there are no explicitly initialized elements.", "[dcl.init.aggr]/3.3")
55+
-> aggregate_explicit_is_union
56+
}
57+
}
58+
59+
// 20
60+
{
61+
YN_QUESTION_NODE(aggregate_explicit_is_union, "Is the aggregate a union?", "[dcl.init.aggr]/20", aggregate_explicit_list_union_is_excess_explicit_init, aggregate_initialize_explicit)
62+
YN_QUESTION_NODE(aggregate_explicit_list_union_is_excess_explicit_init, "Is there more than one explicitly initialized element?", "[dcl.init.aggr]/20", NEW_ILL_FORMED(), aggregate_initialize_explicit)
63+
}
64+
65+
// 4
66+
{
67+
INSTRUCTION_NODE(aggregate_initialize_explicit, "The explicitly initialized elements are initialized as follows:", "[dcl.init.aggr]/4")
68+
-> INSTRUCTION_NODE(aggregate_initialize_explicit_foreach, "For each explicitly initialized element...", "[dcl.init.aggr]/4")
69+
-> aggregate_initialize_explicit_is_anon_union
70+
71+
// 4.1
72+
{
73+
YN_QUESTION_NODE(aggregate_initialize_explicit_is_anon_union, "Is the element an anonymous union member?", "[dcl.init.aggr]/4.1", aggregate_initialize_explicit_union_is_designated, aggregate_initialize_explicit_copy_kind)
74+
YN_QUESTION_NODE(aggregate_initialize_explicit_union_is_designated, "Is the initializer list a brace-enclosed designated-iniitializer-list?", "[dcl.init.aggr]/4.1", aggregate_initialize_explicit_union_is_duplicate_designator, aggregate_initialize_explicit_copy_kind)
75+
76+
YN_QUESTION_NODE(aggregate_initialize_explicit_union_is_duplicate_designator, "Is there more than one designator that names a member of that anonymous union member?", "[dcl.init.aggr]/4.1", NEW_ILL_FORMED(), aggregate_initialization_explicit_union_defn_d)
77+
78+
INSTRUCTION_NODE(aggregate_initialization_explicit_union_defn_d, "Let D be the designated-initializer-clause naming a member of the anonymous union member.", "[dcl.init.aggr]/4.1")
79+
-> INSTRUCTION_NODE(aggregate_initialize_explicit_union_init, "Initialize the element with the braced-init-list { D }.")
80+
-> NEW_RECURSE()
81+
-> aggregate_initialize_explicit_repeat_next
82+
}
83+
84+
// 4.2
85+
{
86+
QUESTION_NODE(aggregate_initialize_explicit_copy_kind, "What is the kind of brace initializer?", "[dcl.init.aggr]/4.2")
87+
aggregate_initialize_explicit_copy_kind -> aggregate_initialize_explicit_copy_init_list [label="initializer-list"]
88+
aggregate_initialize_explicit_copy_kind -> aggregate_initialize_explicit_copy_designated [label="designated-initializer-list"]
89+
90+
INSTRUCTION_NODE(aggregate_initialize_explicit_copy_init_list, "Copy-initialize the element from the corresponding initializer-clause.", "[dcl.init.aggr]/4.2")
91+
-> NEW_RECURSE()
92+
-> aggregate_initialize_explicit_is_narrowing_checked
93+
94+
INSTRUCTION_NODE(aggregate_initialize_explicit_copy_designated, "Initialize the element with the brace-or-equal-initializer of the corresponding designated-initializer-clause.", "[dcl.init.aggr]/4.2")
95+
-> NEW_RECURSE()
96+
-> aggregate_initialize_explicit_is_narrowing_checked
97+
98+
YN_QUESTION_NODE(aggregate_initialize_explicit_is_narrowing_checked, "Is the initializer of the form \"assignment-expression\" or \"= assignment-expression\"?", "[dcl.init.aggr]/4.2", aggregate_initialize_explicit_is_narrowing, aggregate_initialize_explicit_repeat_next)
99+
YN_QUESTION_NODE(aggregate_initialize_explicit_is_narrowing, "Is a narrowing conversion required to convert the expression?", "[dcl.init.aggr]/4.2", NEW_ILL_FORMED(), aggregate_initialize_explicit_repeat_next)
100+
}
101+
102+
INSTRUCTION_NODE(aggregate_initialize_explicit_repeat_next, "Repeat with the next explicitly initialized element.")
103+
-> aggregate_initialize_nonexplicit_is_union [label="Once done with all explicitly initialized elements"]
104+
105+
LOOP_BACKEDGE(aggregate_initialize_explicit_repeat_next, aggregate_initialize_explicit_foreach)
106+
}
107+
108+
// 5
109+
{
110+
YN_QUESTION_NODE(aggregate_initialize_nonexplicit_is_union, "Is the aggregate a union?", "[dcl.init.aggr]/5", aggregate_initialize_nonexplicit_union_is_list_empty, aggregate_initialize_nonexplicit_nonunion)
111+
112+
INSTRUCTION_NODE(aggregate_initialize_nonexplicit_nonunion, "For each non-explicitly-initialized element:", "[dcl.init.aggr]/5")
113+
aggregate_initialize_nonexplicit_nonunion -> aggregate_initialize_nonexplicit_nonunion_has_dflt_mem_init
114+
115+
// 5.1
116+
{
117+
YN_QUESTION_NODE(aggregate_initialize_nonexplicit_nonunion_has_dflt_mem_init, "Does the element have a default member initializer?", "[dcl.init.aggr]/5.1", aggregate_initialize_nonexplicit_nonunion_dflt_mem_init, aggregate_initialize_nonexplicit_nonunion_is_reference)
118+
119+
INSTRUCTION_NODE(aggregate_initialize_nonexplicit_nonunion_dflt_mem_init, "The element is initialized from that initializer.", "[dcl.init.aggr]/5.1")
120+
-> NEW_RECURSE()
121+
-> aggregate_initialize_nonexplicit_nonunion_repeat_next
122+
}
123+
124+
// 5.2
125+
{
126+
YN_QUESTION_NODE(aggregate_initialize_nonexplicit_nonunion_is_reference, "Is the element a reference?", "[dcl.init.aggr]/5.2", NEW_ILL_FORMED(), aggregate_initialize_nonexplicit_nonunion_copy_init)
127+
128+
INSTRUCTION_NODE(aggregate_initialize_nonexplicit_nonunion_copy_init, "The element is copy-initialized from an empty initializer list.", "[dcl.init.aggr]/5.2")
129+
-> NEW_RECURSE()
130+
-> aggregate_initialize_nonexplicit_nonunion_repeat_next
131+
}
132+
133+
INSTRUCTION_NODE(aggregate_initialize_nonexplicit_nonunion_repeat_next, "Repeat with the next non-explicitly-initialized element.")
134+
-> NEW_DONE() [label="Once done with all explicitly initialized elements"]
135+
136+
LOOP_BACKEDGE(aggregate_initialize_nonexplicit_nonunion_repeat_next, aggregate_initialize_nonexplicit_nonunion)
137+
138+
QUESTION_NODE(aggregate_initialize_nonexplicit_union_is_list_empty, "Is the initializer list empty?", "[dcl.init.aggr]/5")
139+
aggregate_initialize_nonexplicit_union_is_list_empty -> aggregate_initialize_nonexplicit_union_empty_has_dflt [label="Yes"]
140+
LINK_TO_DONE(aggregate_initialize_nonexplicit_union_is_list_empty, [label="No"])
141+
142+
// 5.3
143+
{
144+
YN_QUESTION_NODE(aggregate_initialize_nonexplicit_union_empty_has_dflt, "Does any variant member of the union have a default member initializer?", "[dcl.init.aggr]/5.4", aggregate_initialize_nonexplicit_union_dflt_mem, aggregate_initialize_nonexplicit_union_first_mem)
145+
146+
INSTRUCTION_NODE(aggregate_initialize_nonexplicit_union_dflt_mem, "That member is initialized from its default member initializer.", "[dcl.init.aggr]/5.4")
147+
-> NEW_RECURSE()
148+
-> NEW_DONE()
149+
}
150+
151+
// 5.4
152+
{
153+
INSTRUCTION_NODE(aggregate_initialize_nonexplicit_union_first_mem, "The first member of the union (if any) is copy-initialized from an empty initializer list.", "[dcl.init.aggr]/5.5")
154+
-> NEW_RECURSE()
155+
-> NEW_DONE()
156+
}
157+
}
158+
}
159+
160+
#endif

0 commit comments

Comments
 (0)