summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-10 16:24:26 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-10 16:24:26 +0000
commit2a1274904a9ddd3db9aba160e2d094090e99bcfd (patch)
tree99368d90c8e0b51f751a07819e6cdd7a699961c6 /gcc
parent1e4ebc0da7ef9dcb5f35a71436c30e0e2877c458 (diff)
downloadgcc-2a1274904a9ddd3db9aba160e2d094090e99bcfd.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@58983 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-decl.c10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/c90-idem-qual-2.c7
-rw-r--r--gcc/testsuite/gcc.dg/c99-idem-qual-2.c6
5 files changed, 31 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index de77168a9a7..0dd5df257cd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index e5a43fe0f25..9c3b58fc78f 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3b511f56264..a205a79dd06 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..c9bb6f7e252
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c90-idem-qual-2.c
@@ -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
index 00000000000..dd9f932b979
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-idem-qual-2.c
@@ -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" } */