xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/gcc.dg/c99-fordecl-1.c (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /* Test for C99 declarations in for loops.  */
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   int j = 0;
13   int i = -1;
14   for (int i = 1; i <= 10; i++)
15     j += i;
16   if (j != 55)
17     abort ();
18   if (i != -1)
19     abort ();
20   j = 0;
21   for (auto int i = 1; i <= 10; i++)
22     j += i;
23   if (j != 55)
24     abort ();
25   if (i != -1)
26     abort ();
27   j = 0;
28   for (register int i = 1; i <= 10; i++)
29     j += i;
30   if (j != 55)
31     abort ();
32   if (i != -1)
33     abort ();
34   exit (0);
35 }
36