File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic -Wno-gnu-folding-constant %s
2
+ // RUN: %clang_cc1 -verify -std=c23 -Wall -pedantic -Wno-gnu-folding-constant %s
3
+
4
+ /* WG14 N3451: Yes
5
+ * Initialization of anonymous structures and unions
6
+ *
7
+ * This paper allows initialization of anonymous structure and union members
8
+ * within the containing object.
9
+ */
10
+ // expected-no-diagnostics
11
+
12
+ constexpr struct {
13
+ int a : 10 ;
14
+ int : 12 ;
15
+ long b ;
16
+ } s = { 1 , 2 };
17
+ static_assert (s .a == 1 && s .b == 2 );
18
+
19
+ constexpr union {
20
+ int : 16 ;
21
+ char c ;
22
+ } u = {3 };
23
+ static_assert (u .c == 3 );
24
+
25
+ constexpr struct {
26
+ union {
27
+ float a ;
28
+ int b ;
29
+ void * p ;
30
+ };
31
+ char c ;
32
+ } t = {{.b = 1 }, 2 };
33
+ static_assert (t .b == 1 && t .c == 2 );
34
+
35
+ constexpr struct {
36
+ union {
37
+ float a ;
38
+ int b ;
39
+ void * p ;
40
+ };
41
+ char c ;
42
+ } v = {.b = 1 , 2 };
43
+ static_assert (v .b == 1 && v .c == 2 );
Original file line number Diff line number Diff line change @@ -279,7 +279,7 @@ <h2 id="c2y">C2y implementation status</h2>
279
279
< tr >
280
280
< td > Initialization of anonymous structures and unions</ td >
281
281
< td > < a href ="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3451.pdf "> N3451</ a > </ td >
282
- < td class ="unknown " align ="center "> Unknown </ td >
282
+ < td class ="full " align ="center "> Yes </ td >
283
283
</ tr >
284
284
< tr >
285
285
< td > Slay Some Earthly Demons X</ td >
You can’t perform that action at this time.
0 commit comments