diff options
author | Jason Merrill <jason@redhat.com> | 2011-01-11 06:30:07 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-01-11 06:30:07 -0500 |
commit | a67e7daab5abd73d150874c62812ae94f093fbe3 (patch) | |
tree | 6de7c93efa146c7b2059b094ad367dcb5e7c66ce /gcc/cp/init.c | |
parent | 41d04a8dfe0313dd2a4e2501d9ab6d1f06378dbf (diff) | |
download | gcc-a67e7daab5abd73d150874c62812ae94f093fbe3.zip gcc-a67e7daab5abd73d150874c62812ae94f093fbe3.tar.gz gcc-a67e7daab5abd73d150874c62812ae94f093fbe3.tar.bz2 |
re PR c++/46658 (internal compiler error on cp/init.c)
PR c++/46658
* init.c (build_new_1): Handle value-init in templates differently.
From-SVN: r168655
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 9c3dd32..1546bf8 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2294,7 +2294,22 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, explicit_value_init_p = true; } - if (array_p) + if (processing_template_decl && explicit_value_init_p) + { + /* build_value_init doesn't work in templates, and we don't need + the initializer anyway since we're going to throw it away and + rebuild it at instantiation time, so just build up a single + constructor call to get any appropriate diagnostics. */ + init_expr = cp_build_indirect_ref (data_addr, RO_NULL, complain); + if (TYPE_NEEDS_CONSTRUCTING (elt_type)) + init_expr = build_special_member_call (init_expr, + complete_ctor_identifier, + init, elt_type, + LOOKUP_NORMAL, + complain); + stable = stabilize_init (init_expr, &init_preeval_expr); + } + else if (array_p) { tree vecinit = NULL_TREE; if (*init && VEC_length (tree, *init) == 1 @@ -2343,8 +2358,7 @@ 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 || processing_template_decl)) + if (TYPE_NEEDS_CONSTRUCTING (type) && !explicit_value_init_p) { init_expr = build_special_member_call (init_expr, complete_ctor_identifier, @@ -2354,17 +2368,11 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, } else if (explicit_value_init_p) { - 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); - } + /* 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 { |