PR c/14517
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Mar 2004 00:45:37 +0000 (00:45 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Mar 2004 00:45:37 +0000 (00:45 +0000)
        * c-decl.c (grokdeclarator): Don't warn for duplicate qualifiers
        except for pedantic c90 mode.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79286 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/gcc.dg/c90-dupqual-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c99-dupqual-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu89-dupqual-1.c [new file with mode: 0644]

index 2db8147..49ecfe6 100644 (file)
@@ -1,3 +1,9 @@
+2004-03-10  Richard Henderson  <rth@redhat.com>
+
+       PR c/14517
+       * c-decl.c (grokdeclarator): Don't warn for duplicate qualifiers
+       except for pedantic c90 mode.
+
 2004-03-10  Kelley Cook  <kcook@gcc.gnu.org>
 
        * configure.ac: Bump AC_PREREQ to 2.59.
index c296bb9..e59789b 100644 (file)
@@ -3372,7 +3372,7 @@ grokdeclarator (tree declarator, tree declspecs,
                {
                  if (i == RID_CONST || i == RID_VOLATILE || i == RID_RESTRICT)
                    {
-                     if (!flag_isoc99)
+                     if (pedantic && !flag_isoc99)
                        pedwarn ("duplicate `%s'", IDENTIFIER_POINTER (id));
                    }
                  else
@@ -3629,12 +3629,15 @@ grokdeclarator (tree declarator, tree declspecs,
   volatilep
     = !! (specbits & 1 << (int) RID_VOLATILE) + TYPE_VOLATILE (element_type);
   inlinep = !! (specbits & (1 << (int) RID_INLINE));
-  if (constp > 1 && ! flag_isoc99)
-    pedwarn ("duplicate `const'");
-  if (restrictp > 1 && ! flag_isoc99)
-    pedwarn ("duplicate `restrict'");
-  if (volatilep > 1 && ! flag_isoc99)
-    pedwarn ("duplicate `volatile'");
+  if (pedantic && !flag_isoc99)
+    {
+      if (constp > 1)
+       pedwarn ("duplicate `const'");
+      if (restrictp > 1)
+       pedwarn ("duplicate `restrict'");
+      if (volatilep > 1)
+       pedwarn ("duplicate `volatile'");
+    }
   if (! flag_gen_aux_info && (TYPE_QUALS (type)))
     type = TYPE_MAIN_VARIANT (type);
   type_quals = ((constp ? TYPE_QUAL_CONST : 0)
@@ -4087,12 +4090,15 @@ grokdeclarator (tree declarator, tree declspecs,
 
              if (erred)
                error ("invalid type modifier within pointer declarator");
-             if (constp > 1 && ! flag_isoc99)
-               pedwarn ("duplicate `const'");
-             if (volatilep > 1 && ! flag_isoc99)
-               pedwarn ("duplicate `volatile'");
-             if (restrictp > 1 && ! flag_isoc99)
-               pedwarn ("duplicate `restrict'");
+             if (pedantic && !flag_isoc99)
+               {
+                 if (constp > 1)
+                   pedwarn ("duplicate `const'");
+                 if (volatilep > 1)
+                   pedwarn ("duplicate `volatile'");
+                 if (restrictp > 1)
+                   pedwarn ("duplicate `restrict'");
+               }
 
              type_quals = ((constp ? TYPE_QUAL_CONST : 0)
                            | (restrictp ? TYPE_QUAL_RESTRICT : 0)
diff --git a/gcc/testsuite/gcc.dg/c90-dupqual-1.c b/gcc/testsuite/gcc.dg/c90-dupqual-1.c
new file mode 100644 (file)
index 0000000..14838c7
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+typedef const int CI;
+const const int c1;            /* { dg-error "duplicate" } */
+const CI c2;                   /* { dg-error "duplicate" } */
+const CI *c3;                  /* { dg-error "duplicate" } */
+
+typedef volatile int VI;
+volatile volatile int v1;      /* { dg-error "duplicate" } */
+volatile VI v2;                        /* { dg-error "duplicate" } */
+volatile VI *v3;               /* { dg-error "duplicate" } */
diff --git a/gcc/testsuite/gcc.dg/c99-dupqual-1.c b/gcc/testsuite/gcc.dg/c99-dupqual-1.c
new file mode 100644 (file)
index 0000000..2e6d7e1
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+typedef const int CI;
+const const int c1;            /* { dg-bogus "duplicate" } */
+const CI c2;                   /* { dg-bogus "duplicate" } */
+const CI *c3;                  /* { dg-bogus "duplicate" } */
+
+typedef volatile int VI;
+volatile volatile int v1;      /* { dg-bogus "duplicate" } */
+volatile VI v2;                        /* { dg-bogus "duplicate" } */
+volatile VI *v3;               /* { dg-bogus "duplicate" } */
diff --git a/gcc/testsuite/gcc.dg/gnu89-dupqual-1.c b/gcc/testsuite/gcc.dg/gnu89-dupqual-1.c
new file mode 100644 (file)
index 0000000..9bd1db0
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu89 -Werror" } */
+
+typedef const int CI;
+const const int c1;            /* { dg-bogus "duplicate" } */
+const CI c2;                   /* { dg-bogus "duplicate" } */
+const CI *c3;                  /* { dg-bogus "duplicate" } */
+
+typedef volatile int VI;
+volatile volatile int v1;      /* { dg-bogus "duplicate" } */
+volatile VI v2;                        /* { dg-bogus "duplicate" } */
+volatile VI *v3;               /* { dg-bogus "duplicate" } */