Debian Codegraph @

gcc/testsuite/g++.dg/ext/attr-copy-2.C

raw
1 /* PR c/89685 - ICE on attribute copy with a compound expression
2 { dg-do compile }
3 { dg-options "-Wall -Wno-unused-value -Wno-int-to-pointer-cast" } */
4
5 #if __cplusplus <= 199711L
6 # define static_assert(expr) typedef char Assert [1 - !(expr) * 2]
7 #endif
8
9 #define ATTR(...) __attribute__ ((__VA_ARGS__))
10
11 typedef struct ATTR (packed) A { ATTR (packed) unsigned bf: 1; } A;
12
13 typedef struct B
14 {
15 struct A a;
16 struct A *pa;
17 struct A &ra;
18 } B;
19
20 extern struct A a;
21 extern struct A *pa;
22 extern struct A &ra;
23 extern B b;
24 extern B ab[1];
25 extern B *pb;
26 extern B &rb;
27
28 typedef struct C
29 {
30 ATTR (copy ((struct A *)0)) short m_pa_0; // { dg-warning "attribute ignored" "" { target default_packed } }
31 ATTR (copy ((struct A *)(1, 0))) int m_pa_1_0; // { dg-warning "attribute ignored" "" { target default_packed } }
32 ATTR (copy ((struct A *)(0, 1))) long m_pa_0_1; // { dg-warning "attribute ignored" "" { target default_packed } }
33
34 ATTR (copy (*(struct A *)0)) short m_xpa_0; // { dg-warning "attribute ignored" "" { target default_packed } }
35 ATTR (copy (*(struct A *)(1, 0))) int m_xpa_1_0; // { dg-warning "attribute ignored" "" { target default_packed } }
36 ATTR (copy (*(struct A *)(0, 1))) long m_xpa_0_1; // { dg-warning "attribute ignored" "" { target default_packed } }
37
38 ATTR (copy (((struct A *)0)[0])) short m_arpa_0; // { dg-warning "attribute ignored" "" { target default_packed } }
39 ATTR (copy (((struct A *)(1, 0))[0])) int m_arpa_1_0; // { dg-warning "attribute ignored" "" { target default_packed } }
40 ATTR (copy (((struct A *)(0, 1))[0])) long m_arpa_0_1; // { dg-warning "attribute ignored" "" { target default_packed } }
41
42 ATTR (copy (a)) short m_a; // { dg-warning "attribute ignored" "" { target default_packed } }
43 ATTR (copy (b.a)) int m_b_a; // { dg-warning "attribute ignored" "" { target default_packed } }
44 ATTR (copy (b.pa)) long m_b_pa; // { dg-warning "attribute ignored" "" { target default_packed } }
45 ATTR (copy (b.ra)) long m_b_ra; // { dg-warning "attribute ignored" "" { target default_packed } }
46
47 ATTR (copy (&a)) short m_ara; // { dg-warning "attribute ignored" "" { target default_packed } }
48 ATTR (copy (&b.a)) int m_arb_a; // { dg-warning "attribute ignored" "" { target default_packed } }
49 ATTR (copy (*b.pa)) long m_xb_pa; // { dg-warning "attribute ignored" "" { target default_packed } }
50 ATTR (copy (b.pa[0])) long m_arb_pa; // { dg-warning "attribute ignored" "" { target default_packed } }
51
52 ATTR (copy (*pa)) short m_xpa; // { dg-warning "attribute ignored" "" { target default_packed } }
53 ATTR (copy (pa[0])) short m_arpa; // { dg-warning "attribute ignored" "" { target default_packed } }
54
55 ATTR (copy (ra)) short m_ra; // { dg-warning "attribute ignored" "" { target default_packed } }
56
57 ATTR (copy (ab[0].a)) int m_arab_a; // { dg-warning "attribute ignored" "" { target default_packed } }
58 ATTR (copy (ab[1].pa)) long m_arab_pa; // { dg-warning "attribute ignored" "" { target default_packed } }
59 ATTR (copy (*ab[2].pa)) int m_xarab_pa; // { dg-warning "attribute ignored" "" { target default_packed } }
60 ATTR (copy (ab[3].pa->bf)) unsigned int m_arab_pa_bf: 1;
61 ATTR (copy (ab[4].ra.bf)) unsigned int m_arab_ra_bf: 1;
62
63 ATTR (copy (pb->a)) int m_pb_a; // { dg-warning "attribute ignored" "" { target default_packed } }
64 ATTR (copy (pb->pa)) long m_pb_pa; // { dg-warning "attribute ignored" "" { target default_packed } }
65 ATTR (copy (*pb->pa)) int m_xpb_pa; // { dg-warning "attribute ignored" "" { target default_packed } }
66 ATTR (copy (pb->pa->bf)) unsigned int m_pb_pa_bf: 1;
67 ATTR (copy (pb->ra.bf)) unsigned int m_pb_ra_bf: 1;
68
69 ATTR (copy (rb.a)) int m_rb_a; // { dg-warning "attribute ignored" "" { target default_packed } }
70 ATTR (copy (rb.pa)) long m_rb_pa; // { dg-warning "attribute ignored" "" { target default_packed } }
71 ATTR (copy (*rb.pa)) int m_xrb_pa; // { dg-warning "attribute ignored" "" { target default_packed } }
72 ATTR (copy (rb.pa->bf)) unsigned int m_rb_pa_bf: 1;
73
74 ATTR (aligned (4), copy ((struct A *)(0))) short m_a4_pa_0; // { dg-warning "attribute ignored" "" { target default_packed } }
75 } C;
76
77
78 static_assert (__builtin_has_attribute (((C*)0)->m_pa_0, packed));
79 static_assert (__builtin_has_attribute (((C*)0)->m_pa_1_0, packed));
80 static_assert (__builtin_has_attribute (((C*)0)->m_pa_0_1, packed));
81
82 static_assert (__builtin_has_attribute (((C*)0)->m_xpa_0, packed));
83 static_assert (__builtin_has_attribute (((C*)0)->m_xpa_1_0, packed));
84 static_assert (__builtin_has_attribute (((C*)0)->m_xpa_0_1, packed));
85
86 static_assert (__builtin_has_attribute (((C*)0)->m_ra, packed));
87
88 static_assert (__builtin_has_attribute (((C*)0)->m_arpa_0, packed));
89 static_assert (__builtin_has_attribute (((C*)0)->m_arpa_1_0, packed));
90 static_assert (__builtin_has_attribute (((C*)0)->m_arpa_0_1, packed));
91
92 static_assert (__builtin_has_attribute (((C*)0)->m_a, packed));
93 static_assert (__builtin_has_attribute (((C*)0)->m_b_a, packed));
94 static_assert (__builtin_has_attribute (((C*)0)->m_b_pa, packed));
95 static_assert (__builtin_has_attribute (((C*)0)->m_b_ra, packed));
96
97 static_assert (__builtin_has_attribute (((C*)0)->m_ara, packed));
98 static_assert (__builtin_has_attribute (((C*)0)->m_arb_a, packed));
99 static_assert (__builtin_has_attribute (((C*)0)->m_xb_pa, packed));
100 static_assert (__builtin_has_attribute (((C*)0)->m_arb_pa, packed));
101
102 static_assert (__builtin_has_attribute (((C*)0)->m_xpa, packed));
103 static_assert (__builtin_has_attribute (((C*)0)->m_arpa, packed));
104
105 static_assert (__builtin_has_attribute (((C*)0)->m_arab_a, packed));
106 static_assert (__builtin_has_attribute (((C*)0)->m_arab_pa, packed));
107 static_assert (__builtin_has_attribute (((C*)0)->m_xarab_pa, packed));
108 static_assert (__builtin_has_attribute (((C*)0)->m_arab_pa_bf, packed));
109 static_assert (__builtin_has_attribute (((C*)0)->m_arab_ra_bf, packed));
110
111 static_assert (__builtin_has_attribute (((C*)0)->m_pb_a, packed));
112 static_assert (__builtin_has_attribute (((C*)0)->m_pb_pa, packed));
113 static_assert (__builtin_has_attribute (((C*)0)->m_pb_pa, packed));
114 static_assert (__builtin_has_attribute (((C*)0)->m_pb_pa_bf, packed));
115 static_assert (__builtin_has_attribute (((C*)0)->m_pb_ra_bf, packed));
116
117 static_assert (__builtin_has_attribute (((C*)0)->m_rb_a, packed));
118 static_assert (__builtin_has_attribute (((C*)0)->m_rb_pa, packed));
119 static_assert (__builtin_has_attribute (((C*)0)->m_xrb_pa, packed));
120 static_assert (__builtin_has_attribute (((C*)0)->m_rb_pa_bf, packed));
121
122 static_assert (__builtin_has_attribute (((C*)0)->m_a4_pa_0, packed));
123 static_assert (__builtin_has_attribute (((C*)0)->m_a4_pa_0, aligned));
124 static_assert (__alignof__ (((C*)0)->m_a4_pa_0) == 4);