1 /* Test for multiple declarations and composite types. As in bug 2 13801. Test no problems in debug information generation. */ 3 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */ 4 /* { dg-do compile } */ 5 /* { dg-options "" } */ 6 7 typedef int IA[]; 8 typedef int A10[10]; 9 10 /* Test all combinations of: a variable declared at file scope (no 11 type specifiers, or extern, or static), or just inside a function 12 (with extern), redeclared in an inner scope (with extern), and 13 redeclared in an inner scope when the previous declaration is 14 hidden (with extern, and not if the original declaration was 15 static). Test three times: incomplete variable types; pointers to 16 incomplete types; functions returning such pointers. 17 18 This test only includes the valid code cases, to test debug info 19 generation. (Incomplete static at file scope is not permitted by 20 ISO C, but is accepted by GCC as an extension without 21 -pedantic.) */ 22 23 A10 a5; 24 void f5(void)25f5 (void) 26 { 27 sizeof(a5); 28 { 29 extern IA a5; 30 sizeof(a5); 31 { 32 int a5; 33 { 34 extern A10 a5; 35 sizeof(a5); 36 } 37 } 38 sizeof(a5); 39 } 40 sizeof(a5); 41 } 42 extern A10 a5; 43 44 A10 a7; 45 void f7(void)46f7 (void) 47 { 48 sizeof(a7); 49 { 50 extern A10 a7; 51 sizeof(a7); 52 { 53 int a7; 54 { 55 extern A10 a7; 56 sizeof(a7); 57 } 58 } 59 sizeof(a7); 60 } 61 sizeof(a7); 62 } 63 extern A10 a7; 64 65 extern A10 a13; 66 void f13(void)67f13 (void) 68 { 69 sizeof(a13); 70 { 71 extern IA a13; 72 sizeof(a13); 73 { 74 int a13; 75 { 76 extern A10 a13; 77 sizeof(a13); 78 } 79 } 80 sizeof(a13); 81 } 82 sizeof(a13); 83 } 84 extern A10 a13; 85 86 extern A10 a15; 87 void f15(void)88f15 (void) 89 { 90 sizeof(a15); 91 { 92 extern A10 a15; 93 sizeof(a15); 94 { 95 int a15; 96 { 97 extern A10 a15; 98 sizeof(a15); 99 } 100 } 101 sizeof(a15); 102 } 103 sizeof(a15); 104 } 105 extern A10 a15; 106 107 108 static A10 a18; 109 void f18(void)110f18 (void) 111 { 112 sizeof(a18); 113 { 114 extern IA a18; 115 sizeof(a18); 116 } 117 sizeof(a18); 118 } 119 extern A10 a18; 120 121 static A10 a19; 122 void f19(void)123f19 (void) 124 { 125 sizeof(a19); 126 { 127 extern A10 a19; 128 sizeof(a19); 129 } 130 sizeof(a19); 131 } 132 extern A10 a19; 133 134 A10 *b5; 135 void g5(void)136g5 (void) 137 { 138 sizeof(*b5); 139 { 140 extern IA *b5; 141 sizeof(*b5); 142 { 143 int b5; 144 { 145 extern A10 *b5; 146 sizeof(*b5); 147 } 148 } 149 sizeof(*b5); 150 } 151 sizeof(*b5); 152 } 153 extern A10 *b5; 154 155 A10 *b7; 156 void g7(void)157g7 (void) 158 { 159 sizeof(*b7); 160 { 161 extern A10 *b7; 162 sizeof(*b7); 163 { 164 int b7; 165 { 166 extern A10 *b7; 167 sizeof(*b7); 168 } 169 } 170 sizeof(*b7); 171 } 172 sizeof(*b7); 173 } 174 extern A10 *b7; 175 176 extern A10 *b13; 177 void g13(void)178g13 (void) 179 { 180 sizeof(*b13); 181 { 182 extern IA *b13; 183 sizeof(*b13); 184 { 185 int b13; 186 { 187 extern A10 *b13; 188 sizeof(*b13); 189 } 190 } 191 sizeof(*b13); 192 } 193 sizeof(*b13); 194 } 195 extern A10 *b13; 196 197 extern A10 *b15; 198 void g15(void)199g15 (void) 200 { 201 sizeof(*b15); 202 { 203 extern A10 *b15; 204 sizeof(*b15); 205 { 206 int b15; 207 { 208 extern A10 *b15; 209 sizeof(*b15); 210 } 211 } 212 sizeof(*b15); 213 } 214 sizeof(*b15); 215 } 216 extern A10 *b15; 217 218 static A10 *b18; 219 void g18(void)220g18 (void) 221 { 222 sizeof(*b18); 223 { 224 extern IA *b18; 225 sizeof(*b18); 226 } 227 sizeof(*b18); 228 } 229 extern A10 *b18; 230 231 static A10 *b19; 232 void g19(void)233g19 (void) 234 { 235 sizeof(*b19); 236 { 237 extern A10 *b19; 238 sizeof(*b19); 239 } 240 sizeof(*b19); 241 } 242 extern A10 *b19; 243 244 A10 *c5 (void); 245 void h5(void)246h5 (void) 247 { 248 sizeof(*c5()); 249 { 250 extern IA *c5 (void); 251 sizeof(*c5()); 252 { 253 int c5; 254 { 255 extern A10 *c5 (void); 256 sizeof(*c5()); 257 } 258 } 259 sizeof(*c5()); 260 } 261 sizeof(*c5()); 262 } c5(void)263A10 *c5 (void) { return 0; } 264 265 A10 *c7 (void); 266 void h7(void)267h7 (void) 268 { 269 sizeof(*c7()); 270 { 271 extern A10 *c7 (void); 272 sizeof(*c7()); 273 { 274 int c7; 275 { 276 extern A10 *c7 (void); 277 sizeof(*c7()); 278 } 279 } 280 sizeof(*c7()); 281 } 282 sizeof(*c7()); 283 } c7(void)284A10 *c7 (void) { return 0; } 285 286 extern A10 *c13 (void); 287 void h13(void)288h13 (void) 289 { 290 sizeof(*c13()); 291 { 292 extern IA *c13 (void); 293 sizeof(*c13()); 294 { 295 int c13; 296 { 297 extern A10 *c13 (void); 298 sizeof(*c13()); 299 } 300 } 301 sizeof(*c13()); 302 } 303 sizeof(*c13()); 304 } c13(void)305extern A10 *c13 (void) { return 0; } 306 307 extern A10 *c15 (void); 308 void h15(void)309h15 (void) 310 { 311 sizeof(*c15()); 312 { 313 extern A10 *c15 (void); 314 sizeof(*c15()); 315 { 316 int c15; 317 { 318 extern A10 *c15 (void); 319 sizeof(*c15()); 320 } 321 } 322 sizeof(*c15()); 323 } 324 sizeof(*c15()); 325 } c15(void)326extern A10 *c15 (void) { return 0; } 327 328 static A10 *c18 (void); 329 void h18(void)330h18 (void) 331 { 332 sizeof(*c18()); 333 { 334 extern IA *c18 (void); 335 sizeof(*c18()); 336 } 337 sizeof(*c18()); 338 } c18(void)339static A10 *c18 (void) { return 0; } 340 341 static A10 *c19 (void); 342 void h19(void)343h19 (void) 344 { 345 sizeof(*c19()); 346 { 347 extern A10 *c19 (void); 348 sizeof(*c19()); 349 } 350 sizeof(*c19()); 351 } c19(void)352static A10 *c19 (void) { return 0; } 353