+2018-06-07 Marek Polacek <polacek@redhat.com>
+
+ PR c/85318
+ * c-decl.c (check_for_loop_decls): Add -Wc90-c99-compat warning about
+ for loop initial declarations.
+
2018-05-30 David Pagan <dave.pagan@oracle.com>
PR c/55976
}
return NULL_TREE;
}
+ else
+ pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support %<for%> loop "
+ "initial declarations");
+
/* C99 subclause 6.8.5 paragraph 3:
[#3] The declaration part of a for statement shall only
+2018-06-07 Marek Polacek <polacek@redhat.com>
+
+ PR c/85318
+ * gcc.dg/Wc90-c99-compat-10.c: New test.
+ * gcc.dg/Wc90-c99-compat-11.c: New test.
+ * gcc.dg/Wc90-c99-compat-12.c: New test.
+ * gcc.dg/Wc90-c99-compat-9.c: New test.
+
2018-06-07 Paul Koning <ni1d@arrl.net>
* gcc.c-torture/compile/20180605-1.c: New test.
--- /dev/null
+/* PR c/85318 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu11 -Wc90-c99-compat -pedantic-errors" } */
+
+extern void bar (int);
+
+void
+foo (int n)
+{
+ for (int i = 0; i < n; i++) /* { dg-warning "ISO C90 does not support .for. loop" } */
+ bar (i);
+}
--- /dev/null
+/* PR c/85318 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu11 -Wc90-c99-compat -Wno-pedantic" } */
+
+extern void bar (int);
+
+void
+foo (int n)
+{
+ for (int i = 0; i < n; i++) /* { dg-warning "ISO C90 does not support .for. loop" } */
+ bar (i);
+}
--- /dev/null
+/* PR c/85318 */
+/* { dg-do compile } */
+/* { dg-options "-Wpedantic" } */
+
+extern void bar (int);
+
+void
+foo (int n)
+{
+ for (int i = 0; i < n; i++) /* { dg-bogus "ISO C90 does not support .for. loop" } */
+ bar (i);
+}
--- /dev/null
+/* PR c/85318 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wc90-c99-compat -pedantic-errors" } */
+
+extern void bar (int);
+
+void
+foo (int n)
+{
+ for (int i = 0; i < n; i++) /* { dg-warning "ISO C90 does not support .for. loop" } */
+ bar (i);
+}