re PR c/38243 (Restrict constraint violation not an error with -pedantic-errors)
authorJoseph Myers <joseph@codesourcery.com>
Sun, 19 Apr 2009 18:25:07 +0000 (19:25 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sun, 19 Apr 2009 18:25:07 +0000 (19:25 +0100)
PR c/38243
* c-decl.c (shadow_tag_warned): Diagnose use of restrict when
declaring a tag.

testsuite:
* gcc.dg/c99-restrict-3.c: New test.

From-SVN: r146356

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/c99-restrict-3.c [new file with mode: 0644]

index 2566ff7e457035f560981a238b2dfe95b359a8a7..48f1f6c7b3bcd47a6636f52228d82276288349d0 100644 (file)
@@ -1,3 +1,9 @@
+2009-04-19  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/38243
+       * c-decl.c (shadow_tag_warned): Diagnose use of restrict when
+       declaring a tag.
+
 2009-04-19  Diego Novillo  <dnovillo@google.com>
 
        * toplev.c (compile_file): Move call to coverage_finish ...
index 62262034d8cecf856fb23d11fe3bf4eb926686b4..796f1eaadf32ddfe2ca2df21d707104a8cb7b34f 100644 (file)
@@ -2883,6 +2883,12 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned)
 
          found_tag = true;
 
+         if (declspecs->restrict_p)
+           {
+             error ("invalid use of %<restrict%>");
+             warned = 1;
+           }
+
          if (name == 0)
            {
              if (warned != 1 && code != ENUMERAL_TYPE)
index bb2fab66e6556aa78053ca619628118731752087..fd41b3225e4ef8d1978d2583bb37fa0e2b1b5f07 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-19  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/38243
+       * gcc.dg/c99-restrict-3.c: New test.
+
 2009-04-19  Joseph Myers  <joseph@codesourcery.com>
 
        PR preprocessor/20078
diff --git a/gcc/testsuite/gcc.dg/c99-restrict-3.c b/gcc/testsuite/gcc.dg/c99-restrict-3.c
new file mode 100644 (file)
index 0000000..e5200a5
--- /dev/null
@@ -0,0 +1,7 @@
+/* restrict qualifiers on non-pointers must be diagnosed even when
+   only a tag is being declared.  PR 38243.  */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+restrict struct s; /* { dg-error "restrict" } */
+restrict union u; /* { dg-error "restrict" } */