re PR middle-end/33272 (Compiler does not take advantage of restrict)
authorJoseph Myers <joseph@codesourcery.com>
Sun, 2 Sep 2007 00:11:20 +0000 (01:11 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sun, 2 Sep 2007 00:11:20 +0000 (01:11 +0100)
PR middle-end/33272
* c-decl.c (grokdeclarator): Apply qualifiers to type of parameter
decayed from array.

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

From-SVN: r128018

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

index 2a7373633e8ded22c02da0fc9e5d145a0f587047..a29fbb2680fbe08514e99b47f55d036d2bf1d8eb 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-02  Joseph Myers  <joseph@codesourcery.com>
+
+       PR middle-end/33272
+       * c-decl.c (grokdeclarator): Apply qualifiers to type of parameter
+       decayed from array.
+
 2007-09-01  Kazu Hirata  <kazu@codesourcery.com>
 
        * config/arm/arm.c, config/rs6000/ppu_intrinsics.h,
index 714cf62ba03ea553355363c84e60cfe5ed32b90d..d2f4832aafbeb864ac3b4244f889bdc96a9c8ae1 100644 (file)
@@ -4719,6 +4719,8 @@ grokdeclarator (const struct c_declarator *declarator,
              type = c_build_qualified_type (type, type_quals);
            type = build_pointer_type (type);
            type_quals = array_ptr_quals;
+           if (type_quals)
+             type = c_build_qualified_type (type, type_quals);
 
            /* We don't yet implement attributes in this context.  */
            if (array_ptr_attrs != NULL_TREE)
index 95c522f754388e4631e004a7e2f10a0f4c51dcb2..d2b7b7d0c066e72d0c215982ab4e758d73690e93 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-02  Joseph Myers  <joseph@codesourcery.com>
+
+       PR middle-end/33272
+       * gcc.dg/c99-arraydecl-3.c: New test.
+
 2007-08-31 Douglas Gregor <doug.gregor@gmail.com>
 
        PR c++/32597
diff --git a/gcc/testsuite/gcc.dg/c99-arraydecl-3.c b/gcc/testsuite/gcc.dg/c99-arraydecl-3.c
new file mode 100644 (file)
index 0000000..2ab927d
--- /dev/null
@@ -0,0 +1,20 @@
+/* Test for C99 forms of array declarator.  Test restrict qualifiers
+   properly applied to type of parameter.  */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+void
+f0 (int a[restrict])
+{
+  int **b = &a; /* { dg-error "discards qualifiers" } */
+  int *restrict *c = &a;
+}
+
+void
+f1 (a)
+     int a[restrict];
+{
+  int **b = &a; /* { dg-error "discards qualifiers" } */
+  int *restrict *c = &a;
+}