diff options
author | Jason Merrill <jason@redhat.com> | 2017-03-01 20:58:30 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-03-01 20:58:30 -0500 |
commit | 9a642ccae4ba5ca86c58f7770fd833158530bf88 (patch) | |
tree | a5e071e800e22c73c4e996eec76b100110eb382d /gcc/cp/init.c | |
parent | 2b83483746b7b66f51ada58f5ac2a5f821154935 (diff) | |
download | gcc-9a642ccae4ba5ca86c58f7770fd833158530bf88.zip gcc-9a642ccae4ba5ca86c58f7770fd833158530bf88.tar.gz gcc-9a642ccae4ba5ca86c58f7770fd833158530bf88.tar.bz2 |
Class template argument deduction in new-expression
Class template argument deduction in new-expression
* init.c (build_new): Handle deduction from no initializer.
* parser.c (cp_parser_new_expression): Don't require a single
expression for class template deduction.
* typeck2.c (cxx_incomplete_type_diagnostic): Fix diagnostic for
class template placeholder.
* pt.c (tsubst_copy) [TEMPLATE_DECL]: Handle dependent context.
(tsubst_copy_and_build) [TEMPLATE_ID_EXPR]: Handle SCOPE_REF.
(redeclare_class_template): Set TEMPLATE_TYPE_PARM_FOR_CLASS.
From-SVN: r245826
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 7ded37e..191fe13 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3478,15 +3478,19 @@ build_new (vec<tree, va_gc> **placement, tree type, tree nelts, if (type == error_mark_node) return error_mark_node; - if (nelts == NULL_TREE && vec_safe_length (*init) == 1 + if (nelts == NULL_TREE /* Don't do auto deduction where it might affect mangling. */ && (!processing_template_decl || at_function_scope_p ())) { tree auto_node = type_uses_auto (type); if (auto_node) { - tree d_init = (**init)[0]; - d_init = resolve_nondeduced_context (d_init, complain); + tree d_init = NULL_TREE; + if (vec_safe_length (*init) == 1) + { + d_init = (**init)[0]; + d_init = resolve_nondeduced_context (d_init, complain); + } type = do_auto_deduction (type, d_init, auto_node); } } |