Skip to content

Commit c9447c6

Browse files
author
Yuanfang Chen
committed
[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.
1 parent 0081671 commit c9447c6

File tree

2 files changed

+10
-29
lines changed

2 files changed

+10
-29
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,14 +1110,8 @@ NormalizedConstraint::fromConstraintExpr(Sema &S, NamedDecl *D, const Expr *E) {
11101110

11111111
// C++2a [temp.param]p4:
11121112
// [...] If T is not a pack, then E is E', otherwise E is (E' && ...).
1113-
//
1114-
// Using the pattern suffices because the partial ordering rules guarantee
1115-
// the template paramaters are equivalent.
1116-
if (auto *FoldE = dyn_cast<const CXXFoldExpr>(E)) {
1117-
assert(FoldE->isRightFold() && FoldE->getOperator() == BO_LAnd);
1118-
assert(E->IgnoreParenImpCasts() == E);
1119-
E = FoldE->getPattern();
1120-
}
1113+
// Fold expression is considered atomic constraints per current wording.
1114+
// See http://cplusplus.github.io/concepts-ts/ts-active.html#28
11211115

11221116
if (LogicalBinOp BO = E) {
11231117
auto LHS = fromConstraintExpr(S, D, BO.getLHS());

clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,8 @@ template<C T, E auto M, int W, A S,
4444
typename... Z>
4545
void foo(T, U<T, M, W, S, Z...>);
4646

47-
// check auto template parameter pack.
48-
template<C T, auto M, int W, A S,
49-
template<typename, auto, int, A, auto...> class U,
50-
C auto... Z>
51-
void foo2(T, U<T, M, W, S, Z...>) = delete;
52-
template<C T, auto M, int W, A S,
53-
template<typename, auto, int, A, auto...> class U,
54-
D auto... Z>
55-
void foo2(T, U<T, M, W, S, Z...>) = delete;
56-
template<C T, auto M, int W, A S,
57-
template<typename, auto, int, A, auto...> class U,
58-
E auto... Z>
59-
void foo2(T, U<T, M, W, S, Z...>);
60-
6147
void bar(S<int, 1, 1, A{}, int> s, S2<int, 1, 1, A{}, 0, 0u> s2) {
6248
foo(0, s);
63-
foo2(0, s2);
6449
}
6550

6651
template<C auto... T> void bar2();
@@ -110,8 +95,9 @@ template<D T, C V> struct Y4<V, T>; // expected-error {{class template partial s
11095
template<C auto T> struct W1;
11196
template<D auto T> struct W1<T> {};
11297

113-
template<C auto... T> struct W2;
114-
template<D auto... T> struct W2<T...> {};
98+
// See http://cplusplus.github.io/concepts-ts/ts-active.html#28
99+
// template<C auto... T> struct W2;
100+
// template<D auto... T> struct W2<T...> {};
115101

116102
template<class T, class U>
117103
concept C1 = C<T> && C<U>;
@@ -121,8 +107,9 @@ concept D1 = D<T> && C<U>;
121107
template<C1<A> auto T> struct W3;
122108
template<D1<A> auto T> struct W3<T> {};
123109

124-
template<C1<A> auto... T> struct W4;
125-
template<D1<A> auto... T> struct W4<T...> {};
110+
// See http://cplusplus.github.io/concepts-ts/ts-active.html#28
111+
// template<C1<A> auto... T> struct W4;
112+
// template<D1<A> auto... T> struct W4<T...> {};
126113

127114
// FIXME: enable once Clang support non-trivial auto on NTTP.
128115
// template<C auto* T> struct W5;
@@ -133,9 +120,9 @@ template<D1<A> auto... T> struct W4<T...> {};
133120
// template<D auto& T> struct W6<T> {};
134121

135122
struct W1<0> w1;
136-
struct W2<0> w2;
123+
// struct W2<0> w2;
137124
struct W3<0> w3;
138-
struct W4<0> w4;
125+
// struct W4<0> w4;
139126
// FIXME: enable once Clang support non-trivial auto on NTTP.
140127
// struct W5<(int*)nullptr> w5;
141128
// struct W6<w5> w6;

0 commit comments

Comments
 (0)