From c9447c62966e5ec60ec277e4a7d75420224f53f6 Mon Sep 17 00:00:00 2001 From: Yuanfang Chen Date: Sat, 22 Oct 2022 20:17:06 -0700 Subject: [PATCH] [Clang] fold expression is considered atomic during constraints normalization `|| fold` is not disjunction; `&& fold` is not conjunction. Both are atomic per current wording. See http://cplusplus.github.io/concepts-ts/ts-active.html#28. D128750 accidentally tried to partially addresss this which is not desirable. This patch reverts that part and associated test cases. --- clang/lib/Sema/SemaConcept.cpp | 10 ++------ .../temp.decls/temp.fct/temp.func.order/p6.cpp | 29 ++++++---------------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 9809ccb..484c024 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -1110,14 +1110,8 @@ NormalizedConstraint::fromConstraintExpr(Sema &S, NamedDecl *D, const Expr *E) { // C++2a [temp.param]p4: // [...] If T is not a pack, then E is E', otherwise E is (E' && ...). - // - // Using the pattern suffices because the partial ordering rules guarantee - // the template paramaters are equivalent. - if (auto *FoldE = dyn_cast(E)) { - assert(FoldE->isRightFold() && FoldE->getOperator() == BO_LAnd); - assert(E->IgnoreParenImpCasts() == E); - E = FoldE->getPattern(); - } + // Fold expression is considered atomic constraints per current wording. + // See http://cplusplus.github.io/concepts-ts/ts-active.html#28 if (LogicalBinOp BO = E) { auto LHS = fromConstraintExpr(S, D, BO.getLHS()); diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp index bdd1c37..d6e6d73 100644 --- a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp +++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp @@ -44,23 +44,8 @@ template void foo(T, U); -// check auto template parameter pack. -template class U, - C auto... Z> -void foo2(T, U) = delete; -template class U, - D auto... Z> -void foo2(T, U) = delete; -template class U, - E auto... Z> -void foo2(T, U); - void bar(S s, S2 s2) { foo(0, s); - foo2(0, s2); } template void bar2(); @@ -110,8 +95,9 @@ template struct Y4; // expected-error {{class template partial s template struct W1; template struct W1 {}; -template struct W2; -template struct W2 {}; +// See http://cplusplus.github.io/concepts-ts/ts-active.html#28 +// template struct W2; +// template struct W2 {}; template concept C1 = C && C; @@ -121,8 +107,9 @@ concept D1 = D && C; template auto T> struct W3; template auto T> struct W3 {}; -template auto... T> struct W4; -template auto... T> struct W4 {}; +// See http://cplusplus.github.io/concepts-ts/ts-active.html#28 +// template auto... T> struct W4; +// template auto... T> struct W4 {}; // FIXME: enable once Clang support non-trivial auto on NTTP. // template struct W5; @@ -133,9 +120,9 @@ template auto... T> struct W4 {}; // template struct W6 {}; struct W1<0> w1; -struct W2<0> w2; +// struct W2<0> w2; struct W3<0> w3; -struct W4<0> w4; +// struct W4<0> w4; // FIXME: enable once Clang support non-trivial auto on NTTP. // struct W5<(int*)nullptr> w5; // struct W6 w6; -- 2.7.4