diff options
author | Jakub Jelinek <jakub@redhat.com> | 2001-12-12 20:12:16 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2001-12-12 20:12:16 +0100 |
commit | 59c83dbf283e0dcf89ecfcfcbab856682291842a (patch) | |
tree | 52579c466b178af3b34b3b7f1c35b83542ee7516 /gcc/c-typeck.c | |
parent | 3af37d3f59fae068635c004403868f317eb732af (diff) | |
download | gcc-59c83dbf283e0dcf89ecfcfcbab856682291842a.tar.gz |
c-typeck.c (digest_init): Allow initializing static storage duration objects with compound literals.
* c-typeck.c (digest_init): Allow initializing
static storage duration objects with compound literals.
* doc/extend.texi (Compound literals): Document the extension.
* gcc.dg/gnu89-init-1.c: New test.
From-SVN: r47945
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r-- | gcc/c-typeck.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 56775049a1c..f3f7d096964 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4780,8 +4780,19 @@ digest_init (type, init, require_constant, constructor_constant) { if (code == POINTER_TYPE) inside_init = default_function_array_conversion (inside_init); - else if (code == ARRAY_TYPE && TREE_CODE (inside_init) != STRING_CST - && TREE_CODE (inside_init) != CONSTRUCTOR) + + if (require_constant && !flag_isoc99 + && TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR) + { + /* As an extension, allow initializing objects with static storage + duration with compound literals (which are then treated just as + the brace enclosed list they contain). */ + tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init); + inside_init = DECL_INITIAL (decl); + } + + if (code == ARRAY_TYPE && TREE_CODE (inside_init) != STRING_CST + && TREE_CODE (inside_init) != CONSTRUCTOR) { error_init ("array initialized from non-constant array expression"); return error_mark_node; |