Commit e52c093a by Paolo Carlini Committed by Paolo Carlini

re PR c++/84768 (ICE with failed class template argument deduction because of…

re PR c++/84768 (ICE with failed class template argument deduction because of invalid template parameter)

/cp
2018-04-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84768
	* pt.c (rewrite_template_parm): If the first argument is
	error_mark_node return it immediately.
	(build_deduction_guide): Check the return value of the
	latter for error_mark_node.
	(do_class_deduction): Check the return value of the latter.

/testsuite
2018-04-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84768
	* g++.dg/cpp1z/class-deduction52.C: New.

From-SVN: r259049
parent 83afe9b5
2018-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84768
* pt.c (rewrite_template_parm): If the first argument is
error_mark_node return it immediately.
(build_deduction_guide): Check the return value of the
latter for error_mark_node.
(do_class_deduction): Check the return value of the latter.
2018-04-03 Jason Merrill <jason@redhat.com> 2018-04-03 Jason Merrill <jason@redhat.com>
* semantics.c (finish_if_stmt_cond): Use * semantics.c (finish_if_stmt_cond): Use
......
...@@ -25834,6 +25834,9 @@ static tree ...@@ -25834,6 +25834,9 @@ static tree
rewrite_template_parm (tree olddecl, unsigned index, unsigned level, rewrite_template_parm (tree olddecl, unsigned index, unsigned level,
tree tsubst_args, tsubst_flags_t complain) tree tsubst_args, tsubst_flags_t complain)
{ {
if (olddecl == error_mark_node)
return error_mark_node;
tree oldidx = get_template_parm_index (olddecl); tree oldidx = get_template_parm_index (olddecl);
tree newtype; tree newtype;
...@@ -25969,6 +25972,7 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain) ...@@ -25969,6 +25972,7 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain)
else else
{ {
++processing_template_decl; ++processing_template_decl;
bool ok = true;
fn_tmpl fn_tmpl
= (TREE_CODE (ctor) == TEMPLATE_DECL ? ctor = (TREE_CODE (ctor) == TEMPLATE_DECL ? ctor
...@@ -26039,6 +26043,8 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain) ...@@ -26039,6 +26043,8 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain)
tree olddecl = TREE_VALUE (oldelt); tree olddecl = TREE_VALUE (oldelt);
tree newdecl = rewrite_template_parm (olddecl, index, level, tree newdecl = rewrite_template_parm (olddecl, index, level,
tsubst_args, complain); tsubst_args, complain);
if (newdecl == error_mark_node)
ok = false;
tree newdef = tsubst_template_arg (TREE_PURPOSE (oldelt), tree newdef = tsubst_template_arg (TREE_PURPOSE (oldelt),
tsubst_args, complain, ctor); tsubst_args, complain, ctor);
tree list = build_tree_list (newdef, newdecl); tree list = build_tree_list (newdef, newdecl);
...@@ -26060,7 +26066,10 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain) ...@@ -26060,7 +26066,10 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain)
current_template_parms = save_parms; current_template_parms = save_parms;
} }
--processing_template_decl; --processing_template_decl;
if (!ok)
return error_mark_node;
} }
if (!memtmpl) if (!memtmpl)
...@@ -26187,6 +26196,8 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags, ...@@ -26187,6 +26196,8 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags,
for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (type)); iter; ++iter) for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (type)); iter; ++iter)
{ {
tree guide = build_deduction_guide (*iter, outer_args, complain); tree guide = build_deduction_guide (*iter, outer_args, complain);
if (guide == error_mark_node)
return error_mark_node;
if ((flags & LOOKUP_ONLYCONVERTING) if ((flags & LOOKUP_ONLYCONVERTING)
&& DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide))) && DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide)))
elided = true; elided = true;
...@@ -26238,6 +26249,8 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags, ...@@ -26238,6 +26249,8 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags,
if (gtype) if (gtype)
{ {
tree guide = build_deduction_guide (gtype, outer_args, complain); tree guide = build_deduction_guide (gtype, outer_args, complain);
if (guide == error_mark_node)
return error_mark_node;
cands = lookup_add (guide, cands); cands = lookup_add (guide, cands);
} }
} }
......
2018-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84768
* g++.dg/cpp1z/class-deduction52.C: New.
2018-04-03 Jakub Jelinek <jakub@redhat.com> 2018-04-03 Jakub Jelinek <jakub@redhat.com>
PR c++/85147 PR c++/85147
......
// PR c++/84768
// { dg-additional-options -std=c++17 }
template<typename> struct A {};
template<typename T> struct B
{
template<X Y> B(A<T>); // { dg-error "declared" }
};
B b = A<void>();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment