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.
This commit is contained in:
parent
c270abe832
commit
05f1493811
5 changed files with 38 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
2020-04-22 Patrick Palka <ppalka@redhat.com>
|
||||
|
||||
PR c++/67825
|
||||
* g++.dg/concepts/diagnostic10.C: New test.
|
||||
* g++.dg/cpp2a/concepts-pr67178.C: Adjust dg-message.
|
||||
|
||||
2020-04-21 Patrick Palka <ppalka@redhat.com>
|
||||
|
||||
PR c++/94549
|
||||
* g++.dg/concepts/inherit-ctor3.C: Adjust expected diagnostics.
|
||||
* g++.dg/cpp2a/concepts-inherit-ctor4.C: New test.
|
||||
* g++.dg/cpp2a/concepts-inherit-ctor4.C: Likewise.
|
||||
* g++.dg/cpp2a/concepts-inherit-ctor8.C: New test.
|
||||
|
||||
2020-04-21 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
|
18
gcc/testsuite/g++.dg/concepts/diagnostic10.C
Normal file
18
gcc/testsuite/g++.dg/concepts/diagnostic10.C
Normal file
|
@ -0,0 +1,18 @@
|
|||
// PR c++/67825
|
||||
// { dg-do compile { target concepts } }
|
||||
// { dg-additional-options "-fconcepts-diagnostics-depth=2" }
|
||||
|
||||
template<typename T>
|
||||
requires requires (T t) { t.f; } // { dg-error "invalid use of non-static member function" }
|
||||
void foo() { }
|
||||
|
||||
struct S
|
||||
{
|
||||
int f();
|
||||
};
|
||||
|
||||
void
|
||||
bar()
|
||||
{
|
||||
foo<S>(); // { dg-error "unsatisfied constraints" }
|
||||
}
|
|
@ -12,7 +12,7 @@ concept C0 = requires (auto x) { // { dg-error "placeholder type" }
|
|||
template<typename T>
|
||||
concept C1 = requires (C1 auto x) { // { dg-error "not been declared|placeholder|two or more|in requirements" }
|
||||
x; // { dg-error "not declared" }
|
||||
{ x } -> c; // { dg-message "not declared|does not satisfy" }
|
||||
{ x } -> c; // { dg-message "is invalid" }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
Loading…
Add table
Reference in a new issue