From: jason Date: Thu, 21 Aug 2003 05:24:02 +0000 (+0000) Subject: PR c++/11614 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=30bedc1fe9c0c0c83a90602d78b1ebbcdf14ba9d;p=thirdparty%2Fgcc.git PR c++/11614 * decl.c (grokdeclarator): Recognize a flexible array based on the type, not the form of the declarator. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70636 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 59a81c13d8c1..fc6ae49f5aca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-08-21 Jason Merrill + + PR c++/11614 + * decl.c (grokdeclarator): Recognize a flexible array based on the + type, not the form of the declarator. + 2003-08-20 Jason Merrill * semantics.c (simplify_aggr_init_expr): Split out from diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1a4dcb2537f4..e35fa07ab691 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