]> gcc.gnu.org Git - gcc.git/commitdiff
c-decl.c (grokdeclarator): Make error for duplicate type qualifiers into a pedwarn...
authorJoseph Myers <jsm@polyomino.org.uk>
Sun, 10 Nov 2002 16:24:26 +0000 (16:24 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sun, 10 Nov 2002 16:24:26 +0000 (16:24 +0000)
* c-decl.c (grokdeclarator): Make error for duplicate type
qualifiers into a pedwarn, disabled for C99.

testsuite:
* gcc.dg/c90-idem-qual-2.c, gcc.dg/c99-idem-qual-2.c: New tests.

From-SVN: r58983

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/c90-idem-qual-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c99-idem-qual-2.c [new file with mode: 0644]

index de77168a9a7b5815f71b72b986a122dae72be1eb..0dd5df257cdaa0e381e2a5bd11bf62e98be4ebef 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-10  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       * c-decl.c (grokdeclarator): Make error for duplicate type
+       qualifiers into a pedwarn, disabled for C99.
+
 2002-11-10  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * config/mmix/mmix.h (FUNCTION_ARG_CALLEE_COPIES): Define the same
index e5a43fe0f25d633e5cede96d5d58fa8bdcf528ac..9c3b58fc78fa48e674950ceb93c0cd8095377ce2 100644 (file)
@@ -3541,7 +3541,15 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
                    }
                }
              else if (specbits & (1 << (int) i))
-               error ("duplicate `%s'", IDENTIFIER_POINTER (id));
+               {
+                 if (i == RID_CONST || i == RID_VOLATILE || i == RID_RESTRICT)
+                   {
+                     if (!flag_isoc99)
+                       pedwarn ("duplicate `%s'", IDENTIFIER_POINTER (id));
+                   }
+                 else
+                   error ("duplicate `%s'", IDENTIFIER_POINTER (id));
+               }
 
              /* Diagnose "__thread extern".  Recall that this list
                 is in the reverse order seen in the text.  */
index 3b511f56264c7469fcd6ae7c2bfa9693b5d0d853..a205a79dd06ee23f76268d4b38dd354f1c4293c7 100644 (file)
@@ -1,3 +1,7 @@
+2002-11-10  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       * gcc.dg/c90-idem-qual-2.c, gcc.dg/c99-idem-qual-2.c: New tests.
+
 2002-11-09  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * lib/compat.exp (compat-execute): Fix logic error in last
diff --git a/gcc/testsuite/gcc.dg/c90-idem-qual-2.c b/gcc/testsuite/gcc.dg/c90-idem-qual-2.c
new file mode 100644 (file)
index 0000000..c9bb6f7
--- /dev/null
@@ -0,0 +1,7 @@
+/* Test for idempotent type qualifiers: in C99 only.  Test "const const".  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+const const int foo; /* { dg-bogus "warning" "warning in place of error" } */
+/* { dg-error "duplicate" "duplicate type qualifier error" { target *-*-* } 6 } */
diff --git a/gcc/testsuite/gcc.dg/c99-idem-qual-2.c b/gcc/testsuite/gcc.dg/c99-idem-qual-2.c
new file mode 100644 (file)
index 0000000..dd9f932
--- /dev/null
@@ -0,0 +1,6 @@
+/* Test for idempotent type qualifiers: in C99 only.  Test "const const".  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+const const int foo; /* { dg-bogus "duplicate" "duplicate type qualifier error" } */
This page took 0.112042 seconds and 5 git commands to generate.