Skip to content

Commit 113d9d9

Browse files
committed
add test for #135190
1 parent c2eeeef commit 113d9d9

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

clang/test/SemaCXX/cxx2c-fold-exprs.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,46 @@ struct LazyLitMatrix<index_by<Indices...>, init> {
385385
}
386386

387387
}
388+
389+
namespace GH135190 {
390+
template <typename T>
391+
concept A = __is_same_as(T, int) || __is_same_as(T, double) ;
392+
393+
template <typename T>
394+
concept B = A<T> && __is_same_as(T, double);
395+
396+
template <class... Ts>
397+
requires(A<Ts> && ...)
398+
constexpr int g() {
399+
return 1;
400+
}
401+
402+
template <class... Ts>
403+
requires(B<Ts> && ...)
404+
constexpr int g() {
405+
return 2;
406+
}
407+
408+
static_assert(g<double>() == 2);
409+
410+
411+
template <class... Ts>
412+
concept all_A = (A<Ts> && ...);
413+
414+
template <class... Ts>
415+
concept all_B = (B<Ts> && ...);
416+
417+
template <class... Ts>
418+
requires all_A<Ts...>
419+
constexpr int h() {
420+
return 1;
421+
}
422+
423+
template <class... Ts>
424+
requires all_B<Ts...>
425+
constexpr int h() {
426+
return 2;
427+
}
428+
429+
static_assert(h<double>() == 2);
430+
}

clang/test/SemaTemplate/concepts.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,4 +1258,13 @@ template <typename T> concept PerfectSquare = [](){} // expected-note 2{{here}}
12581258
([](auto) { return true; }) < PerfectSquare <class T>;
12591259
// expected-error@-1 {{declaration of 'T' shadows template parameter}} \
12601260
// expected-error@-1 {{a concept definition cannot refer to itself}}
1261+
1262+
}
1263+
namespace GH61811{
1264+
template <class T> struct A { static const int x = 42; };
1265+
template <class Ta> concept A42 = A<Ta>::x == 42;
1266+
template <class Tv> concept Void = __is_same_as(Tv, void);
1267+
template <class Tb, class Ub> concept A42b = Void<Tb> || A42<Ub>;
1268+
template <class Tc> concept R42c = A42b<Tc, Tc&>;
1269+
static_assert (R42c<void>);
12611270
}

0 commit comments

Comments
 (0)