Debian Codegraph @

gcc/testsuite/gcc.dg/c23-tag-composite-3.c

raw
1 /* { dg-do compile }
2 * { dg-options "-std=c23" }
3 */
4
5 // bit-fields
6
7 extern struct foo { int x:3; } x;
8 struct foo { int x:3; } y;
9
10 void f()
11 {
12 extern typeof(*(1 ? &x : &y)) x;
13 &x.x; /* { dg-error "bit-field" } */
14 }
15
16
17 void g()
18 {
19 struct foo { int x:3; } z;
20 extern typeof(*(1 ? &x : &z)) x;
21 &x.x; /* { dg-error "bit-field" } */
22 }
23
24 struct foo { int x:2; }; /* { dg-error "redefinition" } */
25
26 extern struct bar { int x:3; } a;
27
28 void h()
29 {
30 struct bar { signed int x:3; } b;
31 extern typeof(*(1 ? &a : &b)) a;
32 &a.x; /* { dg-error "bit-field" } */
33 }
34
35 void i()
36 {
37 struct bar { unsigned int x:3; } c;
38 (1 ? &a : &c); /* { dg-error "mismatch" } */
39 }
40
41 struct bar { unsigned int x:3; } d; /* { dg-error "redefinition" } */
42 struct bar { signed int x:3; } e; /* { dg-error "redefinition" } */
43
44
45 struct bas { int x:2; int :0; int z:1; };
46 struct bas { int x:2; int :0; int z:1; };
47 struct bas { int x:2; int :1; int z:1; }; /* { dg-error "redefinition" } */
48
49
50