diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2566ff7e457..48f1f6c7b3b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-04-19 Joseph Myers + + PR c/38243 + * c-decl.c (shadow_tag_warned): Diagnose use of restrict when + declaring a tag. + 2009-04-19 Diego Novillo * toplev.c (compile_file): Move call to coverage_finish ... diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 62262034d8c..796f1eaadf3 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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 %"); + warned = 1; + } + if (name == 0) { if (warned != 1 && code != ENUMERAL_TYPE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bb2fab66e65..fd41b3225e4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-04-19 Joseph Myers + + PR c/38243 + * gcc.dg/c99-restrict-3.c: New test. + 2009-04-19 Joseph Myers 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 index 00000000000..e5200a57be9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c99-restrict-3.c @@ -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" } */