diff options
author | Joseph Myers <jsm@polyomino.org.uk> | 2004-09-28 20:35:26 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2004-09-28 20:35:26 +0100 |
commit | ef7878226aa58cf991bcf3b61c43b4e89e4f5a06 (patch) | |
tree | 5fc1cb98a75ae0a4738fa2fd992b53aee46095a7 /gcc/c-decl.c | |
parent | 346c5b01de84d0ca4eebd2934a6e95648919c76f (diff) | |
download | gcc-ef7878226aa58cf991bcf3b61c43b4e89e4f5a06.zip gcc-ef7878226aa58cf991bcf3b61c43b4e89e4f5a06.tar.gz gcc-ef7878226aa58cf991bcf3b61c43b4e89e4f5a06.tar.bz2 |
re PR c/16409 (ICE in size_binop, at fold-const.c)
PR c/16409
* c-decl.c (start_decl): Check for initializing incomplete array
of VLAs.
(build_compound_literal): Check for TYPE being error_mark_node.
* c-parse.in (primary): Check for VLA compound literals.
testsuite:
* gcc.dg/vla-init-2.c, gcc.dg/vla-init-3.c, gcc.dg/vla-init-4.c,
gcc.dg/vla-init-5.c: New tests.
From-SVN: r88248
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 3a2f576..4137876 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -2986,6 +2986,15 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, error ("elements of array %qD have incomplete type", decl); initialized = 0; } + else if (C_DECL_VARIABLE_SIZE (decl)) + { + /* Although C99 is unclear about whether incomplete arrays + of VLAs themselves count as VLAs, it does not make + sense to permit them to be initialized given that + ordinary VLAs may not be initialized. */ + error ("variable-sized object may not be initialized"); + initialized = 0; + } } if (initialized) @@ -3416,9 +3425,14 @@ build_compound_literal (tree type, tree init) /* We do not use start_decl here because we have a type, not a declarator; and do not use finish_decl because the decl should be stored inside the COMPOUND_LITERAL_EXPR rather than added elsewhere as a DECL_EXPR. */ - tree decl = build_decl (VAR_DECL, NULL_TREE, type); + tree decl; tree complit; tree stmt; + + if (type == error_mark_node) + return error_mark_node; + + decl = build_decl (VAR_DECL, NULL_TREE, type); DECL_EXTERNAL (decl) = 0; TREE_PUBLIC (decl) = 0; TREE_STATIC (decl) = (current_scope == file_scope); |