diff options
author | Jason Merrill <jason@redhat.com> | 2003-08-21 01:24:02 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2003-08-21 01:24:02 -0400 |
commit | 01bf0f3e3ac0c920504c26a5c3ad325fea567716 (patch) | |
tree | a154fba48890e878d36a8cd5944b8b1511dcdb56 /gcc/cp/decl.c | |
parent | 9eeb200f8a1270e84d0b1c56aa31d5a93e7a3e86 (diff) | |
download | gcc-01bf0f3e3ac0c920504c26a5c3ad325fea567716.zip gcc-01bf0f3e3ac0c920504c26a5c3ad325fea567716.tar.gz gcc-01bf0f3e3ac0c920504c26a5c3ad325fea567716.tar.bz2 |
re PR c++/11614 (Incorrect handling of pointers to arrays)
PR c++/11614
* decl.c (grokdeclarator): Recognize a flexible array based on the
type, not the form of the declarator.
From-SVN: r70636
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1a4dcb2..e35fa07 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10593,21 +10593,9 @@ grokdeclarator (tree declarator, case ARRAY_REF: { - register tree size; - - size = TREE_OPERAND (declarator, 1); + tree size = TREE_OPERAND (declarator, 1); declarator = TREE_OPERAND (declarator, 0); - /* C99 spells a flexible array member []. */ - if (size == NULL_TREE && decl_context == FIELD && ! staticp - && ! 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; - type = create_array_type_for_decl (dname, type, size); ctype = NULL_TREE; @@ -11355,6 +11343,14 @@ grokdeclarator (tree declarator, } else if (decl_context == FIELD) { + /* The C99 flexible array extension. */ + if (!staticp && TREE_CODE (type) == ARRAY_TYPE + && TYPE_DOMAIN (type) == NULL_TREE) + { + tree itype = compute_array_index_type (dname, integer_zero_node); + type = build_cplus_array_type (TREE_TYPE (type), itype); + } + if (type == error_mark_node) { /* Happens when declaring arrays of sizes which |