llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Imad Aldij (imdj) <details> <summary>Changes</summary> Remove `[expr.prim.req.nested]` check which restrict that local parameters in constraint-expressions can only appear as unevaluated operands. This change makes the treatment of examples like `requires` expressions and other constant expression contexts uniform, consistent with the adoption of P2280. References: - https://cplusplus.github.io/CWG/issues/2517.html - #<!-- -->132825 --- Full diff: https://github.com/llvm/llvm-project/pull/132919.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaExpr.cpp (-11) - (modified) clang/test/SemaCXX/constant-expression-p2280r4.cpp (+13) ``````````diff diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3af6d6c23438f..fa8eeb644c179 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -396,17 +396,6 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs, targetDiag(*Locs.begin(), diag::err_thread_unsupported); } - if (isa<ParmVarDecl>(D) && isa<RequiresExprBodyDecl>(D->getDeclContext()) && - !isUnevaluatedContext()) { - // C++ [expr.prim.req.nested] p3 - // A local parameter shall only appear as an unevaluated operand - // (Clause 8) within the constraint-expression. - Diag(Loc, diag::err_requires_expr_parameter_referenced_in_evaluated_context) - << D; - Diag(D->getLocation(), diag::note_entity_declared_at) << D; - return true; - } - return false; } diff --git a/clang/test/SemaCXX/constant-expression-p2280r4.cpp b/clang/test/SemaCXX/constant-expression-p2280r4.cpp index f22430a0e88a2..9baedd9c6c263 100644 --- a/clang/test/SemaCXX/constant-expression-p2280r4.cpp +++ b/clang/test/SemaCXX/constant-expression-p2280r4.cpp @@ -155,6 +155,19 @@ int g() { } } +namespace GH132825 { +template<typename ArrayType> concept LargeArray = + requires (ArrayType my_array) { requires my_array.size() > 5; }; + +struct Big { + constexpr int size() const { return 100; } +}; + +void g() { + static_assert(LargeArray<Big>); +} +} + namespace GH128409 { int &ff(); int &x = ff(); // nointerpreter-note {{declared here}} `````````` </details> https://github.com/llvm/llvm-project/pull/132919 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits