diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2003-07-22 16:49:48 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-07-22 16:49:48 +0000 |
commit | 817aed6fc35ad24f7a04f6a9ac6616d4a6915ff4 (patch) | |
tree | 9645e711506a5ff94abebf6f0db96dfe083c339e | |
parent | a2f7be91fc5f7347408fb24fe132194be4860bec (diff) | |
download | gcc-817aed6fc35ad24f7a04f6a9ac6616d4a6915ff4.zip gcc-817aed6fc35ad24f7a04f6a9ac6616d4a6915ff4.tar.gz gcc-817aed6fc35ad24f7a04f6a9ac6616d4a6915ff4.tar.bz2 |
re PR c++/11614 (Incorrect handling of pointers to arrays)
cp:
PR c++/11614
* decl.c (grokdeclarator): An array member is only a flexible
array member if the field itself is the array.
testsuite:
* g++.dg/ext/flexary1.C: New test.
From-SVN: r69673
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/flexary1.C | 33 |
4 files changed, 51 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 79565c6..8f37c7e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-07-22 Nathan Sidwell <nathan@codesourcery.com> + + PR c++/11614 + * decl.c (grokdeclarator): An array member is only a flexible + array member if the field itself is the array. + 2003-07-22 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> PR c++/10793 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9e90d9e..22137be 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10615,14 +10615,18 @@ grokdeclarator (tree declarator, register tree size; size = TREE_OPERAND (declarator, 1); + declarator = TREE_OPERAND (declarator, 0); - /* VC++ spells a zero-sized array with []. */ + /* C99 spells a flexible array member []. */ if (size == NULL_TREE && decl_context == FIELD && ! staticp - && ! RIDBIT_SETP (RID_TYPEDEF, specbits)) + && ! RIDBIT_SETP (RID_TYPEDEF, specbits) + && !(declarator && + (TREE_CODE (declarator) == CALL_EXPR + || TREE_CODE (declarator) == INDIRECT_REF + || TREE_CODE (declarator) == ADDR_EXPR + || TREE_CODE (declarator) == ARRAY_REF))) size = integer_zero_node; - declarator = TREE_OPERAND (declarator, 0); - type = create_array_type_for_decl (dname, type, size); ctype = NULL_TREE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eddfa73..085f25d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-07-22 Nathan Sidwell <nathan@codesourcery.com> + + * g++.dg/ext/flexary1.C: New test. + 2003-07-22 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> PR c++/10793 diff --git a/gcc/testsuite/g++.dg/ext/flexary1.C b/gcc/testsuite/g++.dg/ext/flexary1.C new file mode 100644 index 0000000..4033e33 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/flexary1.C @@ -0,0 +1,33 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 Jul 2003 <nathan@codesourcery.com> + +// PR c++ 11614 + +typedef int ary_t[]; + +struct test +{ + ary_t *b; + int (*a)[]; // this is not a flexible array member +}; + +void test(void) +{ + struct test s; + int (*a)[] = 0; + ary_t *b = 0; + + a = s.a; + a = s.b; + + s.a = a; + s.b = a; + + b = s.a; + b = s.b; + + s.a = b; + s.b = b; +} |