PR target/83368
[official-gcc.git] / gcc / testsuite / gcc.dg / c90-scope-1.c
blobad36b7063fb1e26fa1dbf3086e23373dd26062cc
1 /* Test for new block scopes in C99. Inspired by C99 Rationale (N897). */
2 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
3 /* { dg-do run } */
4 /* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
6 struct foo {
7 char a;
8 };
10 extern void abort (void);
11 extern void exit (int);
13 int
14 sfoo (void)
16 if (sizeof (struct foo { int a; double b; char *c; void *d; }))
17 (void) 0;
18 return sizeof (struct foo);
21 int
22 main (void)
24 int t, u;
25 t = sfoo ();
26 u = sizeof (struct foo);
27 /* With C90 scoping rules the new declaration of struct foo is in scope
28 above; with C99 it is local to the if.
30 if (t == u)
31 abort (); /* C99 rules apply. */
32 else
33 exit (0); /* C90 rules apply. */