Skip to content

Commit 8ed77e7

Browse files
committed
Remove the restriction that local parameters in constraint-expressions can only appear as unevaluated operands
1 parent e696f4e commit 8ed77e7

File tree

2 files changed

+0
-18
lines changed

2 files changed

+0
-18
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,6 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
396396
targetDiag(*Locs.begin(), diag::err_thread_unsupported);
397397
}
398398

399-
if (isa<ParmVarDecl>(D) && isa<RequiresExprBodyDecl>(D->getDeclContext()) &&
400-
!isUnevaluatedContext()) {
401-
// C++ [expr.prim.req.nested] p3
402-
// A local parameter shall only appear as an unevaluated operand
403-
// (Clause 8) within the constraint-expression.
404-
Diag(Loc, diag::err_requires_expr_parameter_referenced_in_evaluated_context)
405-
<< D;
406-
Diag(D->getLocation(), diag::note_entity_declared_at) << D;
407-
return true;
408-
}
409-
410399
return false;
411400
}
412401

clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ namespace std_example {
3737
static_assert(D<T1>);
3838
template<D T> struct D_check {}; // expected-note{{because 'short' does not satisfy 'D'}}
3939
using dc1 = D_check<short>; // expected-error{{constraints not satisfied for class template 'D_check' [with T = short]}}
40-
41-
template<typename T>
42-
concept C2 = requires (T a) {
43-
requires sizeof(a) == 4; // OK
44-
requires a == 0; // expected-note{{because 'a == 0' would be invalid: constraint variable 'a' cannot be used in an evaluated context}}
45-
};
46-
static_assert(C2<int>); // expected-note{{because 'int' does not satisfy 'C2'}} expected-error{{static assertion failed}}
4740
}
4841

4942
template<typename T>

0 commit comments

Comments
 (0)