warn_if_shadowing (decl);
}
else
- error_at (DECL_SOURCE_LOCATION (decl), "parameter name omitted");
+ pedwarn_c11 (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic,
+ "ISO C does not support omitting parameter names in "
+ "function definitions before C2X");
}
/* Record the parameter list in the function declaration. */
--- /dev/null
+/* Test omitted parameter names not in C11: -pedantic-errors. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+void f (int) { } /* { dg-error "omitting parameter names" } */
--- /dev/null
+/* Test omitted parameter names not in C11: -pedantic. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic" } */
+
+void f (int) { } /* { dg-warning "omitting parameter names" } */
--- /dev/null
+/* Test omitted parameter names not in C11: -pedantic -Wno-c11-c2x-compat. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic -Wno-c11-c2x-compat" } */
+
+void f (int) { }
--- /dev/null
+/* Test omitted parameter names not in C11: accepted by default in the
+ absence of -pedantic. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11" } */
+
+void f (int) { }
--- /dev/null
+/* Test omitted parameter names in C2x. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+void f (int) { }
--- /dev/null
+/* Test omitted parameter names in C2x. Warning test: there should be
+ no warning for an unnamed parameter being unused. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors -Wall -Wextra" } */
+
+int
+f (int a, int, int c, int d) /* { dg-warning "unused parameter 'd'" } */
+{
+ return a + c;
+}
--- /dev/null
+/* Test omitted parameter names in C2x. Execution test. */
+/* { dg-do run } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+
+extern void abort (void);
+extern void exit (int);
+
+void
+f (int a, int [++a], int b)
+{
+ /* Verify array size expression of unnamed parameter is processed as
+ expected. */
+ if (a != 2 || b != 3)
+ abort ();
+}
+
+int
+main (void)
+{
+ int t[2];
+ f (1, t, 3);
+ exit (0);
+}
--- /dev/null
+/* Test omitted parameter names in C2x: diagnosed with -Wc11-c2x-compat. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */
+
+void f (int) { } /* { dg-warning "omitting parameter names" } */
/* PR c/79758 */
/* { dg-do compile } */
-void fn1 (int[a]) { }; /* { dg-error "undeclared here|parameter name omitted" } */
+void fn1 (int[a]) { }; /* { dg-error "undeclared here" } */
void fn1 (b) { }; /* { dg-error "redefinition" } */
/* { dg-warning "defaults to 'int'" "" { target *-*-* } .-1 } */