aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-10-31 12:19:50 -0400
committerJason Merrill <jason@gcc.gnu.org>2015-10-31 12:19:50 -0400
commit09833a1db1a6a24968cf4575a2a26a8823e3f3ca (patch)
tree7f600eb0fd5a0762ee42e25fac806f0005647212 /gcc/cp
parent79d9b2dea234d3e7c3fbc13ab1d0160ef08e9f59 (diff)
downloadgcc-09833a1db1a6a24968cf4575a2a26a8823e3f3ca.zip
gcc-09833a1db1a6a24968cf4575a2a26a8823e3f3ca.tar.gz
gcc-09833a1db1a6a24968cf4575a2a26a8823e3f3ca.tar.bz2
Improve deduction failure diagnostics.
* pt.c (unify): Don't diagnose no common base if we already have the same template. (do_auto_deduction): Explain deduction failure. From-SVN: r229627
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c14
2 files changed, 17 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a995242..592eb5d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2015-10-31 Jason Merrill <jason@redhat.com>
+ * pt.c (unify): Don't diagnose no common base if we already have
+ the same template.
+ (do_auto_deduction): Explain deduction failure.
+
* pt.c (hash_tmpl_and_args): Use iterative_hash_object on template
uid.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 243464d..c6ef2f5 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19633,7 +19633,16 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
explain_p, &t);
if (!t)
- return unify_no_common_base (explain_p, r, parm, arg);
+ {
+ /* Don't give the derived diagnostic if we're
+ already dealing with the same template. */
+ bool same_template
+ = (CLASSTYPE_TEMPLATE_INFO (arg)
+ && (CLASSTYPE_TI_TEMPLATE (parm)
+ == CLASSTYPE_TI_TEMPLATE (arg)));
+ return unify_no_common_base (explain_p && !same_template,
+ r, parm, arg);
+ }
}
}
else if (CLASSTYPE_TEMPLATE_INFO (arg)
@@ -23500,6 +23509,9 @@ do_auto_deduction (tree type, tree init, tree auto_node,
error ("unable to deduce lambda return type from %qE", init);
else
error ("unable to deduce %qT from %qE", type, init);
+ type_unification_real (tparms, targs, parms, &init, 1, 0,
+ DEDUCE_CALL, LOOKUP_NORMAL,
+ NULL, /*explain_p=*/true);
}
return error_mark_node;
}