diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-04-21 22:18:50 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-04-21 22:18:50 -0400 |
commit | 05f14938111e34edd272628a9268444256735e10 (patch) | |
tree | d6968099e75f5c54e0faee13b9f20c80a70b3747 /gcc/cp | |
parent | c270abe832fe77f34d49c00da20de9b1c6f28ea9 (diff) |
c++: Diagnose invalid use of member function in requires
This updates diagnose_valid_expression to mirror the convert_to_void check added
to tsubst_valid_expression_requirement by r10-7554.
gcc/cp/ChangeLog:
PR c++/67825
* constraint.cc (diagnose_valid_expression): Check convert_to_void here
as well as in tsubst_valid_expression_requirement.
gcc/testsuite/ChangeLog:
PR c++/67825
* g++.dg/concepts/diagnostic10.C: New test.
* g++.dg/cpp2a/concepts-pr67178.C: Adjust dg-message.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/constraint.cc | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 67b571c4408..e7733d0517e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-04-22 Patrick Palka <ppalka@redhat.com> + + PR c++/67825 + * constraint.cc (diagnose_valid_expression): Check convert_to_void here + as well as in tsubst_valid_expression_requirement. + 2020-04-21 Patrick Palka <ppalka@redhat.com> PR c++/94549 diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index d56ec101cd9..c05fafe5da1 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3242,7 +3242,8 @@ static tree diagnose_valid_expression (tree expr, tree args, tree in_decl) { tree result = tsubst_expr (expr, args, tf_none, in_decl, false); - if (result != error_mark_node) + if (result != error_mark_node + && convert_to_void (result, ICV_STATEMENT, tf_none) != error_mark_node) return result; location_t loc = cp_expr_loc_or_input_loc (expr); @@ -3250,7 +3251,10 @@ diagnose_valid_expression (tree expr, tree args, tree in_decl) { /* Replay the substitution error. */ inform (loc, "the required expression %qE is invalid, because", expr); - tsubst_expr (expr, args, tf_error, in_decl, false); + if (result == error_mark_node) + tsubst_expr (expr, args, tf_error, in_decl, false); + else + convert_to_void (result, ICV_STATEMENT, tf_error); } else inform (loc, "the required expression %qE is invalid", expr); |