[PATCH] D138914: Make evaluation of nested requirement consistent with requires expr.
Utkarsh Saxena via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 29 05:20:01 PST 2022
usaxena95 created this revision.
Herald added a project: All.
usaxena95 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Fixes: https://github.com/llvm/llvm-project/issues/45563
template<class T> concept True = true;
template <class T>
concept C1 = requires (T) {
requires True<typename T::value> || True<T>;
};
template <class T>
constexpr bool foo()
requires True<typename T::value> || True<T> {
return true;
}
static_assert(C1<double>); // Previously failed due to SFINAE error
static_assert(foo<int>()); // but this works fine.
The issue here is the discrepancy between how a nested requirement is evaluated <https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplateInstantiate.cpp#L2331> Vs how a non-nested requirement is evaluated <https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaConcept.cpp#L167-L200>.
This patch makes constraint checking consistent for nested requirement
and trailing requires expressions by reusing the same evaluator.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138914
Files:
clang/include/clang/AST/ExprConcepts.h
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
clang/test/SemaTemplate/instantiate-requires-expr.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138914.478539.patch
Type: text/x-patch
Size: 14118 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221129/6b38fa70/attachment-0001.bin>
More information about the cfe-commits
mailing list