Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / attr-copy-8.c
blob7195f6b19f8728207712dfe870d7e12cdac1ebb0
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" } */
5 #define ATTR(...) __attribute__ ((__VA_ARGS__))
7 typedef struct ATTR (packed) A { ATTR (packed) unsigned bf: 1; } A;
9 typedef struct B
11 struct A a;
12 struct A *pa;
13 } B;
15 extern struct A a;
16 extern struct A *pa;
17 extern B b;
18 extern B ab[1];
19 extern B *pb;
21 typedef struct C
23 ATTR (copy ((struct A *)0)) short m_pa_0;
24 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
25 ATTR (copy ((struct A *)(1, 0))) int m_pa_1_0;
26 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
27 ATTR (copy ((struct A *)(0, 1))) long m_pa_0_1;
28 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
30 ATTR (copy (*(struct A *)0)) short m_xpa_0;
31 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
32 ATTR (copy (*(struct A *)(1, 0))) int m_xpa_1_0;
33 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
34 ATTR (copy (*(struct A *)(0, 1))) long m_xpa_0_1;
35 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
37 ATTR (copy (((struct A *)0)[0])) short m_arpa_0;
38 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
39 ATTR (copy (((struct A *)(1, 0))[0])) int m_arpa_1_0;
40 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
41 ATTR (copy (((struct A *)(0, 1))[0])) long m_arpa_0_1;
42 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
44 /* Also exercise COMPONENT_REF, ARRAY_REF, and INDIRECT_REF. */
45 ATTR (copy (a)) short m_ra;
46 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
47 ATTR (copy (b.a)) int m_rb_a;
48 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
49 ATTR (copy (b.pa)) long m_rb_pa;
50 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
52 ATTR (copy (&a)) short m_ara;
53 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
54 ATTR (copy (&b.a)) int m_arb_a;
55 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
56 ATTR (copy (*b.pa)) long m_xb_pa;
57 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
58 ATTR (copy (b.pa[0])) long m_arb_pa;
59 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
61 ATTR (copy (*pa)) short m_xpa;
62 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
63 ATTR (copy (pa[0])) short m_arpa;
64 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
66 ATTR (copy (ab[0].a)) int m_arab_a;
67 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
68 ATTR (copy (ab[1].pa)) long m_arab_pa;
69 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
70 ATTR (copy (*ab[2].pa)) int m_xarab_pa;
71 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
72 ATTR (copy (ab[3].pa->bf)) unsigned int m_arab_pa_bf: 1;
74 ATTR (copy (pb->a)) int m_pb_a;
75 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
76 ATTR (copy (pb->pa)) long m_pb_pa;
77 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
78 ATTR (copy (*pb->pa)) int m_xpb_pa;
79 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
80 ATTR (copy (pb->pa->bf)) unsigned int m_pb_pa_bf: 1;
82 ATTR (aligned (4), copy ((struct A *)(0))) short m_a4_pa_0;
83 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
84 } C;
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));
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));
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));
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));
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));
108 _Static_assert (__builtin_has_attribute (((C*)0)->m_xpa, packed));
109 _Static_assert (__builtin_has_attribute (((C*)0)->m_arpa, packed));
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));
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));
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);