From b09869ff41aa77377645d60115d77177acd3a8cd Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sun, 2 Sep 2007 01:11:20 +0100 Subject: [PATCH] re PR middle-end/33272 (Compiler does not take advantage of restrict) 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 | 6 ++++++ gcc/c-decl.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/c99-arraydecl-3.c | 20 ++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/c99-arraydecl-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2a7373633e8..a29fbb2680f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-09-02 Joseph Myers + + PR middle-end/33272 + * c-decl.c (grokdeclarator): Apply qualifiers to type of parameter + decayed from array. + 2007-09-01 Kazu Hirata * config/arm/arm.c, config/rs6000/ppu_intrinsics.h, diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 714cf62ba03..d2f4832aafb 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 95c522f7543..d2b7b7d0c06 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-09-02 Joseph Myers + + PR middle-end/33272 + * gcc.dg/c99-arraydecl-3.c: New test. + 2007-08-31 Douglas Gregor 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 index 00000000000..2ab927d6ab2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c99-arraydecl-3.c @@ -0,0 +1,20 @@ +/* Test for C99 forms of array declarator. Test restrict qualifiers + properly applied to type of parameter. */ +/* Origin: Joseph Myers */ +/* { 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; +}