diff options
author | Jason Merrill <jason@redhat.com> | 2017-03-17 14:56:22 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-03-17 14:56:22 -0400 |
commit | d1a73b0baead836a8d813a6a63459ef87a270bba (patch) | |
tree | ae76f8effa7e1594edcee55fbfb2ef0d08794b32 /gcc/cp | |
parent | 3b82a32c3e673743f6bbb911efb8be77a7bb1255 (diff) | |
download | gcc-d1a73b0baead836a8d813a6a63459ef87a270bba.zip gcc-d1a73b0baead836a8d813a6a63459ef87a270bba.tar.gz gcc-d1a73b0baead836a8d813a6a63459ef87a270bba.tar.bz2 |
PR c++/78345 - ICE initializing array from lambda.
* init.c (build_aggr_init): Check array initializer.
(build_vec_init): Check the type of a CONSTRUCTOR.
From-SVN: r246244
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/init.c | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a5c150a..7d2a56a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-03-17 Jason Merrill <jason@redhat.com> + PR c++/78345 - ICE initializing array from lambda. + * init.c (build_aggr_init): Check array initializer. + (build_vec_init): Check the type of a CONSTRUCTOR. + PR c++/80073 - C++17 ICE with virtual base. * decl.c (xref_basetypes): Also check for indirect vbases. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 8bfcbde..ebb1245 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1617,6 +1617,10 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) if (init == error_mark_node) return error_mark_node; + location_t init_loc = (init + ? EXPR_LOC_OR_LOC (init, input_location) + : location_of (exp)); + TREE_READONLY (exp) = 0; TREE_THIS_VOLATILE (exp) = 0; @@ -1656,6 +1660,16 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) TREE_TYPE (init) = cv_unqualified (itype); from_array = (itype && same_type_p (TREE_TYPE (init), TREE_TYPE (exp))); + + if (init && !from_array + && !BRACE_ENCLOSED_INITIALIZER_P (init)) + { + if (complain & tf_error) + permerror (init_loc, "array must be initialized " + "with a brace-enclosed initializer"); + else + return error_mark_node; + } } stmt_expr = build_vec_init (exp, NULL_TREE, init, @@ -3945,6 +3959,9 @@ build_vec_init (tree base, tree maxindex, tree init, ? vec_copy_assign_is_trivial (inner_elt_type, init) : !TYPE_NEEDS_CONSTRUCTING (type)) && ((TREE_CODE (init) == CONSTRUCTOR + && (BRACE_ENCLOSED_INITIALIZER_P (init) + || (same_type_ignoring_top_level_qualifiers_p + (atype, TREE_TYPE (init)))) /* Don't do this if the CONSTRUCTOR might contain something that might throw and require us to clean up. */ && (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)) |