summaryrefslogtreecommitdiffstats
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2000-11-19 23:40:37 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2000-11-19 23:40:37 +0000
commit1b82e8583b1e092e52d07a9a8b8abbfecc16e99f (patch)
treeb0963851524845509cecfbe1ac8dbb68d8f147ff /gcc/c-typeck.c
parent1a361d3efefa04669e1fee3502d24e39b7b14e71 (diff)
downloadppe42-gcc-1b82e8583b1e092e52d07a9a8b8abbfecc16e99f.tar.gz
ppe42-gcc-1b82e8583b1e092e52d07a9a8b8abbfecc16e99f.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37576 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index edf73ea00be..ada69a8e395 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -5295,6 +5295,16 @@ push_init_level (implicit)
{
constructor_max_index
= TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
+
+ if (constructor_max_index == NULL_TREE)
+ {
+ /* This is a zero-length array or flexible array member. */
+ if (pedantic)
+ pedwarn_init ("ISO C does not support initialization of flexible array members");
+ if (constructor_depth != 2)
+ error_init ("initialization of zero-length array inside a nested structure");
+ }
+
constructor_index
= convert (bitsizetype,
TYPE_MIN_VALUE
OpenPOWER on IntegriCloud