aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-10-30 22:01:16 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-10-30 22:01:16 -0400
commit56e0346dcb882b07199b8b19616b52f9667e356f (patch)
tree7547594aa1edb233eafc2a8935fc82ee8742e7c5 /gcc/cp
parentd11368e6e0bc88033c2ff8a0e5f534d6d2f36b89 (diff)
downloadgcc-56e0346dcb882b07199b8b19616b52f9667e356f.zip
gcc-56e0346dcb882b07199b8b19616b52f9667e356f.tar.gz
gcc-56e0346dcb882b07199b8b19616b52f9667e356f.tar.bz2
PR c++/92268 - hard error satisfying return-type-requirement
Previously we would put the template arguments for the concept-check in a TEMPLATE_ID and then also pass them to constraints_satisfied_p, which meant that we would try to normalize the concept-check with the fully instantiated arguments, leading to sadness. Simply not passing the args to constraints_satisfied_p fixes the problem. I also noticed that we weren't detecting substitution failure in the constraints, but were silently treating it as success. * constraint.cc (type_deducible_p): Check for substitution failure. (diagnose_compound_requirement): Adjust diagnostic. * pt.c (do_auto_deduction): Don't pass cargs to constraints_satisfied_p. From-SVN: r277654
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/constraint.cc15
-rw-r--r--gcc/cp/pt.c2
3 files changed, 18 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index efb135e..585420a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2019-10-30 Jason Merrill <jason@redhat.com>
+
+ PR c++/92268 - hard error satisfying return-type-requirement
+ * constraint.cc (type_deducible_p): Check for substitution failure.
+ (diagnose_compound_requirement): Adjust diagnostic.
+ * pt.c (do_auto_deduction): Don't pass cargs to
+ constraints_satisfied_p.
+
2019-10-30 Jakub Jelinek <jakub@redhat.com>
PR c++/91369 - Implement P0784R7: constexpr new
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index b8a2645..db2a30c 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -1822,10 +1822,7 @@ tsubst_type_requirement (tree t, tree args, subst_info info)
return finish_type_requirement (EXPR_LOCATION (t), type);
}
-/* True if TYPE can be deduced from EXPR.
-
- FIXME: C++20 compound requirement constraints should be normalized and then
- satisfied rather than substituted. */
+/* True if TYPE can be deduced from EXPR. */
static bool
type_deducible_p (tree expr, tree type, tree placeholder, tree args,
@@ -1839,12 +1836,17 @@ type_deducible_p (tree expr, tree type, tree placeholder, tree args,
substitutes args into any template parameters in the trailing
result type. */
tree saved_constr = PLACEHOLDER_TYPE_CONSTRAINTS (placeholder);
- PLACEHOLDER_TYPE_CONSTRAINTS (placeholder)
+ tree subst_constr
= tsubst_constraint (saved_constr,
args,
info.complain | tf_partial,
info.in_decl);
+ if (subst_constr == error_mark_node)
+ return false;
+
+ PLACEHOLDER_TYPE_CONSTRAINTS (placeholder) = subst_constr;
+
/* Temporarily unlink the canonical type. */
tree saved_type = TYPE_CANONICAL (placeholder);
TYPE_CANONICAL (placeholder) = NULL_TREE;
@@ -3139,7 +3141,8 @@ diagnose_compound_requirement (tree req, tree args, tree in_decl)
if (!type_deducible_p (expr, type, placeholder, args, quiet))
{
tree orig_expr = TREE_OPERAND (req, 0);
- inform (loc, "type deduction from %qE failed", orig_expr);
+ inform (loc, "%qE does not satisfy return-type-requirement",
+ orig_expr);
/* Further explain the reason for the error. */
type_deducible_p (expr, type, placeholder, args, noisy);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c5675dd..414140a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -28138,7 +28138,7 @@ do_auto_deduction (tree type, tree init, tree auto_node,
/* Rebuild the check using the deduced arguments. */
check = build_concept_check (cdecl, cargs, tf_none);
- if (!constraints_satisfied_p (check, cargs))
+ if (!constraints_satisfied_p (check))
{
if (complain & tf_warning_or_error)
{