aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/typeck2.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-04 20:42:58 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-04 20:42:58 +0000
commitc2ab9194438e2805bdc12916ebf40890267d62f5 (patch)
tree0984f230491f3ffe8ce6006150b0dcd48d966e4b /gcc/cp/typeck2.c
parentc30da20973a19b7b3f134b07dc72b33d6d3fd136 (diff)
Implement P0091R2, Template argument deduction for class templates.
* parser.c (cp_parser_simple_type_specifier): Parse class placeholder. Use the location of the beginning of the type-specifier. (cp_parser_init_declarator): Parse deduction guide. (cp_parser_diagnose_invalid_type_name): Mention class deduction. (cp_parser_type_id_1): Don't accept class placeholder as template arg. * cp-tree.h (CLASS_PLACEHOLDER_TEMPLATE): New. * decl.c (grokdeclarator): Check for uninitialized auto here. (start_decl_1): Not here. (cp_finish_decl): Or here. Don't collapse a list when doing class deduction. (grokfndecl): Check deduction guide scope and body. * error.c (dump_decl, dump_function_decl, dump_function_name): Handle deduction guides. * pt.c (make_template_placeholder, do_class_deduction): New. (build_deduction_guide, rewrite_template_parm): New. (dguide_name, dguide_name_p, deduction_guide_p): New. (do_auto_deduction): Call do_class_deduction. (splice_late_return_type, is_auto): Handle class placeholders. (template_parms_level_to_args): Split from template_parms_to_args. (tsubst_template_parms_level): Split from tsubst_template_parms. * typeck2.c (build_functional_cast): Handle class placeholder. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240756 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/typeck2.c')
-rw-r--r--gcc/cp/typeck2.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 6e226856edc..a063ea34392 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1952,11 +1952,23 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain)
return error_mark_node;
}
- if (type_uses_auto (type))
+ if (tree anode = type_uses_auto (type))
{
- if (complain & tf_error)
- error ("invalid use of %<auto%>");
- return error_mark_node;
+ if (!CLASS_PLACEHOLDER_TEMPLATE (anode))
+ {
+ if (complain & tf_error)
+ error ("invalid use of %qT", anode);
+ return error_mark_node;
+ }
+ else if (!parms)
+ {
+ if (complain & tf_error)
+ error ("cannot deduce template arguments for %qT from ()", anode);
+ return error_mark_node;
+ }
+ else
+ type = do_auto_deduction (type, parms, anode, complain,
+ adc_variable_type);
}
if (processing_template_decl)