aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@gcc.gnu.org>2000-11-19 15:40:37 -0800
committerRichard Henderson <rth@gcc.gnu.org>2000-11-19 15:40:37 -0800
commita25f12118ff98fe7983907767398ef77c609cc17 (patch)
treeb0963851524845509cecfbe1ac8dbb68d8f147ff /gcc/c-decl.c
parent2650255a57477be0a966f3d3af0c0b71a0e52f0f (diff)
downloadgcc-a25f12118ff98fe7983907767398ef77c609cc17.zip
gcc-a25f12118ff98fe7983907767398ef77c609cc17.tar.gz
gcc-a25f12118ff98fe7983907767398ef77c609cc17.tar.bz2
c-decl.c (grokdeclarator): Support flexible array members.
* c-decl.c (grokdeclarator): Support flexible array members. Use open-ended ranges for these and zero-length arrays. * c-typeck.c (push_init_level): Validate the context of initialization of a zero-length array. * tree.c (int_fits_type_p): Be prepared for missing bounds. * varasm.c (array_size_for_constructor): New. (output_constructor): Use it for arrays of unspecified length. * extend.texi (Zero Length): Mention C99 flexible array members. Document initialization in a top-level struct as valid. From-SVN: r37576
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 8868a11..9da1923 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -4498,9 +4498,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
{
/* A zero-length array cannot be represented with an
unsigned index type, which is what we'll get with
- build_index_type. Create a signed range instead. */
- itype = build_range_type (index_type, size,
- build_int_2 (-1, -1));
+ build_index_type. Create an open-ended range instead. */
+ itype = build_range_type (sizetype, size, NULL_TREE);
}
else
{
@@ -4530,6 +4529,19 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
itype = build_index_type (itype);
}
}
+ else if (decl_context == FIELD)
+ {
+ /* ??? Need to check somewhere that this is a structure
+ and not a union, that this field is last, and that
+ this structure has at least one other named member. */
+
+ if (pedantic && !flag_isoc99 && !in_system_header)
+ pedwarn ("ISO C89 does not support flexible array members");
+
+ /* ISO C99 Flexible array members are effectively identical
+ to GCC's zero-length array extension. */
+ itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
+ }
#if 0
/* This had bad results for pointers to arrays, as in