aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/c99-fordecl-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/c99-fordecl-1.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/c99-fordecl-1.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/c99-fordecl-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/c99-fordecl-1.c
new file mode 100644
index 000000000..faaab1e95
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/c99-fordecl-1.c
@@ -0,0 +1,35 @@
+/* Test for C99 declarations in for loops. */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do run } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ int j = 0;
+ int i = -1;
+ for (int i = 1; i <= 10; i++)
+ j += i;
+ if (j != 55)
+ abort ();
+ if (i != -1)
+ abort ();
+ j = 0;
+ for (auto int i = 1; i <= 10; i++)
+ j += i;
+ if (j != 55)
+ abort ();
+ if (i != -1)
+ abort ();
+ j = 0;
+ for (register int i = 1; i <= 10; i++)
+ j += i;
+ if (j != 55)
+ abort ();
+ if (i != -1)
+ abort ();
+ exit (0);
+}