In gcc/testsuite/: 2011-03-04 Nicola Pero <nicola.pero@meta-innovation.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / c99-fordecl-1.c
blobfaaab1e9539f51441dafeead6063b6450653cb60
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" } */
6 extern void abort (void);
7 extern void exit (int);
9 int
10 main (void)
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);