Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / c11-typeof-2.c
blob3d49ada5fce60f94c1c2fed31fceb0b43d402b2a
1 /* Test GNU extensions __typeof__ and __typeof_unqual__. Valid code. */
2 /* { dg-do run } */
3 /* { dg-options "-std=c11 -pedantic-errors" } */
5 int i;
6 extern __typeof__ (i) i;
7 extern __typeof (int) i;
8 extern __typeof_unqual__ (i) i;
9 extern __typeof_unqual (int) i;
11 volatile int vi;
12 extern __typeof__ (volatile int) vi;
13 extern __typeof (vi) vi;
15 extern __typeof_unqual__ (volatile int) i;
16 extern __typeof_unqual__ (vi) i;
17 extern __typeof__ ((const int) vi) i;
18 extern __typeof ((volatile int) vi) i;
20 const int ci;
21 extern __typeof (const int) ci;
22 extern __typeof (ci) ci;
24 extern __typeof_unqual (const int) i;
25 extern __typeof_unqual (ci) i;
26 extern __typeof__ ((const int) ci) i;
27 extern __typeof__ (+ci) i;
28 extern __typeof (0, ci) i;
29 extern __typeof__ (1 ? ci : ci) i;
30 extern __typeof (0) i;
32 const int fci (void);
33 extern __typeof__ (fci ()) i;
35 _Atomic int ai;
36 extern __typeof (_Atomic int) ai;
37 extern __typeof__ (_Atomic (int)) ai;
38 extern __typeof (ai) ai;
40 extern __typeof_unqual__ (_Atomic int) i;
41 extern __typeof_unqual (_Atomic (int)) i;
42 extern __typeof_unqual__ (ai) i;
43 extern __typeof (+ai) i;
44 extern __typeof__ ((_Atomic int) ai) i;
45 extern __typeof__ (0, ai) i;
46 extern __typeof (1 ? ai : ai) i;
48 _Atomic int fai (void);
49 extern __typeof__ (fai ()) i;
51 _Atomic const volatile int acvi;
52 extern __typeof (int volatile const _Atomic) acvi;
53 extern __typeof (acvi) acvi;
54 extern const _Atomic volatile __typeof (acvi) acvi;
55 extern _Atomic volatile __typeof__ (ci) acvi;
56 extern _Atomic const __typeof (vi) acvi;
57 extern const __typeof__ (ai) volatile acvi;
59 extern __typeof_unqual (acvi) i;
60 extern __typeof_unqual__ (__typeof (acvi)) i;
61 extern __typeof_unqual (_Atomic __typeof_unqual__ (acvi)) i;
63 extern _Atomic __typeof_unqual (acvi) ai;
65 char c;
66 volatile char vc;
67 volatile char *pvc;
68 volatile char *const cpvc;
69 const char *pcc;
70 const char *volatile vpcc;
71 __typeof (*vpcc) cc;
73 extern __typeof__ (*cpvc) vc;
74 extern __typeof_unqual (*cpvc) c;
75 extern __typeof_unqual__ (cpvc) pvc;
76 extern __typeof_unqual__ (vpcc) pcc;
77 extern const char cc;
79 extern __typeof (++vi) i;
80 extern __typeof (++ai) i;
81 extern __typeof__ (--vi) i;
82 extern __typeof (--ai) i;
83 extern __typeof__ (vi++) i;
84 extern __typeof__ (ai++) i;
85 extern __typeof (vi--) i;
86 extern __typeof__ (ai--) i;
88 _Bool b;
89 volatile _Bool vb;
90 _Atomic _Bool ab;
91 extern __typeof__ (++vb) b;
92 extern __typeof__ (++ab) b;
93 extern __typeof (--vb) b;
94 extern __typeof__ (--ab) b;
95 extern __typeof (vb++) b;
96 extern __typeof (ab++) b;
97 extern __typeof__ (vb--) b;
98 extern __typeof (ab--) b;
100 extern __typeof__ (vc = 1) c;
101 extern __typeof__ (vpcc = 0) pcc;
102 extern __typeof (ai *= 2) i;
104 int s = sizeof (__typeof__ (int (*)[++i]));
106 void *vp;
108 extern void abort (void);
109 extern void exit (int);
111 extern int only_used_in_typeof;
113 static int not_defined (void);
115 __typeof (i)
116 main (__typeof (*vp))
118 volatile __typeof__ (only_used_in_typeof) ii = 2;
119 if (ii != 2)
120 abort ();
121 const __typeof__ (not_defined ()) jj = 3;
122 if (jj != 3)
123 abort ();
124 unsigned int u = 1;
125 __typeof__ (u) u2 = 0;
126 __typeof (int (*)[++u2]) p = 0;
127 if (u2 != 1)
128 abort ();
129 if (sizeof (*p) != sizeof (int))
130 abort ();
131 __typeof_unqual (int (*)[++u2]) q = 0;
132 if (u2 != 2)
133 abort ();
134 if (sizeof (*q) != 2 * sizeof (int))
135 abort ();
136 if (sizeof (*p) != sizeof (int))
137 abort ();
138 __typeof (++u2) u3 = 1;
139 if (u2 != u + u3)
140 abort ();
141 __typeof_unqual__ (++u2) u4 = 2;
142 if (u2 != u4)
143 abort ();
144 u = sizeof (__typeof__ (int (*)[++u2]));
145 if (u2 != 2)
146 abort ();
147 u = sizeof (__typeof_unqual (int (*)[++u2]));
148 if (u2 != 2)
149 abort ();
150 __typeof ((int (*)[++u2]) 0) q2;
151 if (u2 != 3)
152 abort ();
153 __typeof ((void) 0, (int (*)[++u2]) 0) q3;
154 if (u2 != 4)
155 abort ();
156 __typeof__ ((int (*)[++u2]) 0, 0) q4;
157 if (u2 != 4)
158 abort ();
159 __typeof_unqual ((int (*)[++u2]) 0) q5;
160 if (u2 != 5)
161 abort ();
162 __typeof_unqual__ ((void) 0, (int (*)[++u2]) 0) q6;
163 if (u2 != 6)
164 abort ();
165 __typeof_unqual__ ((int (*)[++u2]) 0, 0) q7;
166 if (u2 != 6)
167 abort ();
168 int a1[6], a2[6];
169 int (*pa)[u2] = &a1;
170 __typeof (pa = &a2) pp;
171 if (pa != &a2)
172 abort ();
173 __typeof_unqual (pa = &a1) pp2;
174 if (pa != &a1)
175 abort ();
176 exit (0);