]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/attr-copy-8.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / attr-copy-8.c
CommitLineData
ddeae8c8
MS
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#define ATTR(...) __attribute__ ((__VA_ARGS__))
6
7typedef struct ATTR (packed) A { ATTR (packed) unsigned bf: 1; } A;
8
9typedef struct B
10{
11 struct A a;
12 struct A *pa;
13} B;
14
15extern struct A a;
16extern struct A *pa;
17extern B b;
18extern B ab[1];
19extern B *pb;
20
21typedef struct C
22{
23 ATTR (copy ((struct A *)0)) short m_pa_0;
d5a86490 24 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 25 ATTR (copy ((struct A *)(1, 0))) int m_pa_1_0;
d5a86490 26 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 27 ATTR (copy ((struct A *)(0, 1))) long m_pa_0_1;
d5a86490 28 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8
MS
29
30 ATTR (copy (*(struct A *)0)) short m_xpa_0;
d5a86490 31 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 32 ATTR (copy (*(struct A *)(1, 0))) int m_xpa_1_0;
d5a86490 33 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 34 ATTR (copy (*(struct A *)(0, 1))) long m_xpa_0_1;
d5a86490 35 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8
MS
36
37 ATTR (copy (((struct A *)0)[0])) short m_arpa_0;
d5a86490 38 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 39 ATTR (copy (((struct A *)(1, 0))[0])) int m_arpa_1_0;
d5a86490 40 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 41 ATTR (copy (((struct A *)(0, 1))[0])) long m_arpa_0_1;
d5a86490 42 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8
MS
43
44 /* Also exercise COMPONENT_REF, ARRAY_REF, and INDIRECT_REF. */
45 ATTR (copy (a)) short m_ra;
d5a86490 46 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 47 ATTR (copy (b.a)) int m_rb_a;
d5a86490 48 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 49 ATTR (copy (b.pa)) long m_rb_pa;
d5a86490 50 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8
MS
51
52 ATTR (copy (&a)) short m_ara;
d5a86490 53 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 54 ATTR (copy (&b.a)) int m_arb_a;
d5a86490 55 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 56 ATTR (copy (*b.pa)) long m_xb_pa;
d5a86490 57 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 58 ATTR (copy (b.pa[0])) long m_arb_pa;
d5a86490 59 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8
MS
60
61 ATTR (copy (*pa)) short m_xpa;
d5a86490 62 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 63 ATTR (copy (pa[0])) short m_arpa;
d5a86490 64 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8
MS
65
66 ATTR (copy (ab[0].a)) int m_arab_a;
d5a86490 67 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 68 ATTR (copy (ab[1].pa)) long m_arab_pa;
d5a86490 69 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 70 ATTR (copy (*ab[2].pa)) int m_xarab_pa;
d5a86490 71 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8
MS
72 ATTR (copy (ab[3].pa->bf)) unsigned int m_arab_pa_bf: 1;
73
74 ATTR (copy (pb->a)) int m_pb_a;
d5a86490 75 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 76 ATTR (copy (pb->pa)) long m_pb_pa;
d5a86490 77 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8 78 ATTR (copy (*pb->pa)) int m_xpb_pa;
d5a86490 79 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8
MS
80 ATTR (copy (pb->pa->bf)) unsigned int m_pb_pa_bf: 1;
81
82 ATTR (aligned (4), copy ((struct A *)(0))) short m_a4_pa_0;
d5a86490 83 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
ddeae8c8
MS
84} C;
85
86
87_Static_assert (__builtin_has_attribute (((C*)0)->m_pa_0, packed));
88_Static_assert (__builtin_has_attribute (((C*)0)->m_pa_1_0, packed));
89_Static_assert (__builtin_has_attribute (((C*)0)->m_pa_0_1, packed));
90
91_Static_assert (__builtin_has_attribute (((C*)0)->m_xpa_0, packed));
92_Static_assert (__builtin_has_attribute (((C*)0)->m_xpa_1_0, packed));
93_Static_assert (__builtin_has_attribute (((C*)0)->m_xpa_0_1, packed));
94
95_Static_assert (__builtin_has_attribute (((C*)0)->m_arpa_0, packed));
96_Static_assert (__builtin_has_attribute (((C*)0)->m_arpa_1_0, packed));
97_Static_assert (__builtin_has_attribute (((C*)0)->m_arpa_0_1, packed));
98
99_Static_assert (__builtin_has_attribute (((C*)0)->m_ra, packed));
100_Static_assert (__builtin_has_attribute (((C*)0)->m_rb_a, packed));
101_Static_assert (__builtin_has_attribute (((C*)0)->m_rb_pa, packed));
102
103_Static_assert (__builtin_has_attribute (((C*)0)->m_ara, packed));
104_Static_assert (__builtin_has_attribute (((C*)0)->m_arb_a, packed));
105_Static_assert (__builtin_has_attribute (((C*)0)->m_xb_pa, packed));
106_Static_assert (__builtin_has_attribute (((C*)0)->m_arb_pa, packed));
107
108_Static_assert (__builtin_has_attribute (((C*)0)->m_xpa, packed));
109_Static_assert (__builtin_has_attribute (((C*)0)->m_arpa, packed));
110
111_Static_assert (__builtin_has_attribute (((C*)0)->m_arab_a, packed));
112_Static_assert (__builtin_has_attribute (((C*)0)->m_arab_pa, packed));
113_Static_assert (__builtin_has_attribute (((C*)0)->m_xarab_pa, packed));
114_Static_assert (__builtin_has_attribute (((C*)0)->m_arab_pa_bf, packed));
115
116_Static_assert (__builtin_has_attribute (((C*)0)->m_pb_a, packed));
117_Static_assert (__builtin_has_attribute (((C*)0)->m_pb_pa, packed));
118_Static_assert (__builtin_has_attribute (((C*)0)->m_xpb_pa, packed));
119_Static_assert (__builtin_has_attribute (((C*)0)->m_pb_pa_bf, packed));
120
121_Static_assert (__builtin_has_attribute (((C*)0)->m_a4_pa_0, packed));
122_Static_assert (__builtin_has_attribute (((C*)0)->m_a4_pa_0, aligned));
123_Static_assert (__alignof__ (((C*)0)->m_a4_pa_0) == 4);