(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
c99-scope-2.c
       1  /* Test for new block scopes in C99.  Test for each new scope.  */
       2  /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
       3  /* { dg-do run } */
       4  /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
       5  
       6  extern void abort (void);
       7  extern void exit (int);
       8  
       9  int
      10  main (void)
      11  {
      12    struct foo { int i0; };
      13    int a, b, c, d;
      14    a = sizeof (struct foo);
      15    if (b = sizeof (struct foo { int i0; int i1; }))
      16      c = sizeof (struct foo { int i0; int i1; int i2; });
      17    if (!(a <= b && b <= c))
      18      abort ();
      19    if ((b = sizeof (struct foo { int i0; int i1; })), 0)
      20      c = sizeof (struct foo { int i0; int i1; int i2; });
      21    else
      22      d = sizeof (struct foo { int i0; int i1; int i2; int i3; });
      23    if (!(a <= b && b <= d))
      24      abort ();
      25    switch (b = sizeof (struct foo { int i0; int i1; }))
      26      default:
      27        c = sizeof (struct foo { int i0; int i1; int i2; });
      28    if (!(a <= b && b <= c))
      29      abort ();
      30    do
      31      c = sizeof (struct foo { int i0; int i1; int i2; });
      32    while ((b = sizeof (struct foo { int i0; int i1; })), 0);
      33    if (!(a <= b && b <= c))
      34      abort ();
      35    d = 1;
      36    while ((b = sizeof (struct foo { int i0; int i1; })), d)
      37      (c = sizeof (struct foo { int i0; int i1; int i2; })), d--;
      38    if (!(a <= b && b <= c))
      39      abort ();
      40    d = 1;
      41    for ((b = sizeof (struct foo { int i0; int i1; })); d; d--)
      42      c = sizeof (struct foo { int i0; int i1; int i2; });
      43    if (!(a <= b && b <= c))
      44      abort ();
      45    d = 1;
      46    for ((b = sizeof (struct foo { int i0; int i1; })); d; d--)
      47      c = sizeof (struct foo);
      48    if (!(a <= b && b == c))
      49      abort ();
      50    d = 1;
      51    for (; (b = sizeof (struct foo { int i0; int i1; })), d; d--)
      52      c = sizeof (struct foo { int i0; int i1; int i2; });
      53    if (!(a <= b && b <= c))
      54      abort ();
      55    d = 1;
      56    for (; (b = sizeof (struct foo { int i0; int i1; })), d; d--)
      57      c = sizeof (struct foo);
      58    if (!(a <= b && b == c))
      59      abort ();
      60    d = 1;
      61    for (; d; (b = sizeof (struct foo { int i0; int i1; })), d--)
      62      c = sizeof (struct foo { int i0; int i1; int i2; });
      63    if (!(a <= b && b <= c))
      64      abort ();
      65    d = 1;
      66    for (; d; (b = sizeof (struct foo { int i0; int i1; })), d--)
      67      c = sizeof (struct foo);
      68    if (!(a <= b && b == c))
      69      abort ();
      70    exit (0);
      71  }