diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-02-07 22:27:55 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-02-07 22:27:55 +0100 |
commit | f11c7048b94d6d0c1a37f1e765fc17a69734daec (patch) | |
tree | 00eb9d8c1970a6ee44878a9aedfc5bdd8718e67a /gcc | |
parent | 12eabbda6bd7fab8482c288ed30c73b15c49680c (diff) | |
download | gcc-f11c7048b94d6d0c1a37f1e765fc17a69734daec.zip gcc-f11c7048b94d6d0c1a37f1e765fc17a69734daec.tar.gz gcc-f11c7048b94d6d0c1a37f1e765fc17a69734daec.tar.bz2 |
re PR c++/56241 (ICE in toplev.c:332 on invalid)
PR c++/56241
* init.c (build_vec_init): Don't append NULL values into new_vec.
(build_zero_init_1): Don't push anything into v if recursive call
returned NULL_TREE.
(build_value_init_noctor): Don't push anything into v if
build_value_init call returned NULL_TREE.
* g++.dg/parse/crash61.C: New test.
From-SVN: r195866
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/init.c | 39 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/crash61.C | 6 |
4 files changed, 39 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 57912b9..6d29ff6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 2013-02-07 Jakub Jelinek <jakub@redhat.com> + PR c++/56241 + * init.c (build_vec_init): Don't append NULL values into new_vec. + (build_zero_init_1): Don't push anything into v if recursive call + returned NULL_TREE. + (build_value_init_noctor): Don't push anything into v if + build_value_init call returned NULL_TREE. + PR c++/56239 * parser.c (cp_parser_token_starts_cast_expression): Renamed to... (cp_parser_tokens_start_cast_expression): ... this. Change parameter diff --git a/gcc/cp/init.c b/gcc/cp/init.c index b9d604b..6f46404 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -253,8 +253,6 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, { constructor_elt ce; - vec_alloc (v, 1); - /* If this is a one element array, we just use a regular init. */ if (tree_int_cst_equal (size_zero_node, max_index)) ce.index = size_zero_node; @@ -265,7 +263,11 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, ce.value = build_zero_init_1 (TREE_TYPE (type), /*nelts=*/NULL_TREE, static_storage_p, NULL_TREE); - v->quick_push (ce); + if (ce.value) + { + vec_alloc (v, 1); + v->quick_push (ce); + } } /* Build a constructor to contain the initializations. */ @@ -447,8 +449,6 @@ build_value_init_noctor (tree type, tsubst_flags_t complain) { constructor_elt ce; - vec_alloc (v, 1); - /* If this is a one element array, we just use a regular init. */ if (tree_int_cst_equal (size_zero_node, max_index)) ce.index = size_zero_node; @@ -456,16 +456,20 @@ build_value_init_noctor (tree type, tsubst_flags_t complain) ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node, max_index); ce.value = build_value_init (TREE_TYPE (type), complain); - v->quick_push (ce); + if (ce.value) + { + if (ce.value == error_mark_node) + return error_mark_node; - if (ce.value == error_mark_node) - return error_mark_node; + vec_alloc (v, 1); + v->quick_push (ce); - /* We shouldn't have gotten here for anything that would need - non-trivial initialization, and gimplify_init_ctor_preeval - would need to be fixed to allow it. */ - gcc_assert (TREE_CODE (ce.value) != TARGET_EXPR - && TREE_CODE (ce.value) != AGGR_INIT_EXPR); + /* We shouldn't have gotten here for anything that would need + non-trivial initialization, and gimplify_init_ctor_preeval + would need to be fixed to allow it. */ + gcc_assert (TREE_CODE (ce.value) != TARGET_EXPR + && TREE_CODE (ce.value) != AGGR_INIT_EXPR); + } } /* Build a constructor to contain the initializations. */ @@ -3469,9 +3473,12 @@ build_vec_init (tree base, tree maxindex, tree init, else { if (do_static_init) - CONSTRUCTOR_APPEND_ELT (new_vec, field, - build_zero_init (TREE_TYPE (e), - NULL_TREE, true)); + { + tree value = build_zero_init (TREE_TYPE (e), NULL_TREE, + true); + if (value) + CONSTRUCTOR_APPEND_ELT (new_vec, field, value); + } saw_non_const = true; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a7642dd..c8ce975 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2013-02-07 Jakub Jelinek <jakub@redhat.com> + PR c++/56241 + * g++.dg/parse/crash61.C: New test. + PR c++/56239 * g++.dg/parse/pr56239.C: New test. diff --git a/gcc/testsuite/g++.dg/parse/crash61.C b/gcc/testsuite/g++.dg/parse/crash61.C new file mode 100644 index 0000000..790df0e --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash61.C @@ -0,0 +1,6 @@ +// PR c++/56241 +// { dg-do compile } + +struct pair { constexpr pair (const) : }; // { dg-error "" } +template <0> make_pair () {} // { dg-error "" } +pair prefix[] = { 0, make_pair } // { dg-error "" } |