From 663174d3f5b4114e970566789a0a5840642c9ad7 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 26 Oct 2004 22:01:51 +0100 Subject: [PATCH] c-parse.in (datadef): Use pedwarn rather than error and warning for diagnostic in case of no... * c-parse.in (datadef): Use pedwarn rather than error and warning for diagnostic in case of no declaration specifiers. testsuite: * gcc.dg/decl-nospec-1.c, gcc.dg/decl-nospec-2.c, gcc.dg/decl-nospec-3.c: New tests. From-SVN: r89605 --- gcc/ChangeLog | 5 +++++ gcc/c-parse.in | 6 +----- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/decl-nospec-1.c | 8 ++++++++ gcc/testsuite/gcc.dg/decl-nospec-2.c | 8 ++++++++ gcc/testsuite/gcc.dg/decl-nospec-3.c | 8 ++++++++ 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/decl-nospec-1.c create mode 100644 gcc/testsuite/gcc.dg/decl-nospec-2.c create mode 100644 gcc/testsuite/gcc.dg/decl-nospec-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a99bb0051eb..2851099342c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-10-26 Joseph S. Myers + + * c-parse.in (datadef): Use pedwarn rather than error and warning + for diagnostic in case of no declaration specifiers. + 2004-10-26 Richard Sandiford PR bootstrap/15747 diff --git a/gcc/c-parse.in b/gcc/c-parse.in index e1146b0a49d..1affab4e7b8 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -407,11 +407,7 @@ save_obstack_position: datadef: setspecs notype_initdecls ';' - { if (pedantic) - error ("ISO C forbids data definition with no type or storage class"); - else - warning ("data definition has no type or storage class"); - + { pedwarn ("data definition has no type or storage class"); POP_DECLSPEC_STACK; } | declspecs_nots setspecs notype_initdecls ';' { POP_DECLSPEC_STACK; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4496f97ce87..5dc3407411b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-10-26 Joseph S. Myers + + * gcc.dg/decl-nospec-1.c, gcc.dg/decl-nospec-2.c, + gcc.dg/decl-nospec-3.c: New tests. + 2004-10-26 Ziemowit Laski * objc.dg/super-class-3.m: New test. diff --git a/gcc/testsuite/gcc.dg/decl-nospec-1.c b/gcc/testsuite/gcc.dg/decl-nospec-1.c new file mode 100644 index 00000000000..20067c16594 --- /dev/null +++ b/gcc/testsuite/gcc.dg/decl-nospec-1.c @@ -0,0 +1,8 @@ +/* Data definition with no type or storage class should receive a + pedwarn, rather than a warning which becomes an error with + -pedantic. Test with no options. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +foo(); /* { dg-warning "warning: data definition has no type or storage class" } */ diff --git a/gcc/testsuite/gcc.dg/decl-nospec-2.c b/gcc/testsuite/gcc.dg/decl-nospec-2.c new file mode 100644 index 00000000000..86e68c01be4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/decl-nospec-2.c @@ -0,0 +1,8 @@ +/* Data definition with no type or storage class should receive a + pedwarn, rather than a warning which becomes an error with + -pedantic. Test with -pedantic. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic" } */ + +foo(); /* { dg-warning "warning: data definition has no type or storage class" } */ diff --git a/gcc/testsuite/gcc.dg/decl-nospec-3.c b/gcc/testsuite/gcc.dg/decl-nospec-3.c new file mode 100644 index 00000000000..6c04e94429d --- /dev/null +++ b/gcc/testsuite/gcc.dg/decl-nospec-3.c @@ -0,0 +1,8 @@ +/* Data definition with no type or storage class should receive a + pedwarn, rather than a warning which becomes an error with + -pedantic. Test with -pedantic-errors. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-pedantic-errors" } */ + +foo(); /* { dg-error "error: data definition has no type or storage class" } */ -- 2.30.2