diff options
author | Jason Merrill <jason@redhat.com> | 2010-08-19 13:01:01 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-08-19 13:01:01 -0400 |
commit | 95d7bdaae984895c2b436fbc445eb47d7c9555b0 (patch) | |
tree | af2e509711d4cc8b32e46b70a6820bd70d73f114 /gcc/cp/init.c | |
parent | ce3beba3df013a2ebffbde6bf691f396dd968f61 (diff) | |
download | gcc-95d7bdaae984895c2b436fbc445eb47d7c9555b0.zip gcc-95d7bdaae984895c2b436fbc445eb47d7c9555b0.tar.gz gcc-95d7bdaae984895c2b436fbc445eb47d7c9555b0.tar.bz2 |
re PR c++/45315 (ICE: tree check: expected aggr_init_expr, have call_expr in build_value_init, at cp/init.c:317)
PR c++/45315
* init.c (build_new_1): Don't use build_value_init in a template.
(build_value_init): Make sure we don't.
From-SVN: r163381
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 8555fad..189bcbe 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -295,6 +295,9 @@ build_value_init (tree type, tsubst_flags_t complain) zero-initializing the object and then calling the default constructor. */ + /* The AGGR_INIT_EXPR tweaking below breaks in templates. */ + gcc_assert (!processing_template_decl); + if (CLASS_TYPE_P (type)) { if (type_has_user_provided_constructor (type)) @@ -2310,7 +2313,8 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, { init_expr = cp_build_indirect_ref (data_addr, RO_NULL, complain); - if (TYPE_NEEDS_CONSTRUCTING (type) && !explicit_value_init_p) + if (TYPE_NEEDS_CONSTRUCTING (type) + && (!explicit_value_init_p || processing_template_decl)) { init_expr = build_special_member_call (init_expr, complete_ctor_identifier, @@ -2320,11 +2324,17 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, } else if (explicit_value_init_p) { - /* Something like `new int()'. */ - tree val = build_value_init (type, complain); - if (val == error_mark_node) - return error_mark_node; - init_expr = build2 (INIT_EXPR, type, init_expr, val); + if (processing_template_decl) + /* Don't worry about it, we'll handle this properly at + instantiation time. */; + else + { + /* Something like `new int()'. */ + tree val = build_value_init (type, complain); + if (val == error_mark_node) + return error_mark_node; + init_expr = build2 (INIT_EXPR, type, init_expr, val); + } } else { |