| 1 |
// RUN: %clang -fsyntax-only -std=c++2a -Xclang -verify -ftemplate-depth=5 -ftemplate-backtrace-limit=4 %s |
| 2 |
|
| 3 |
// RequiresExpr contains invalid requirement. (Eg. Highly recursive template). |
| 4 |
template<int x> |
| 5 |
struct A { static constexpr bool far(); }; |
| 6 |
class B { |
| 7 |
bool data_member; |
| 8 |
friend struct A<1>; |
| 9 |
}; |
| 10 |
|
| 11 |
template<> |
| 12 |
constexpr bool A<0>::far() { return true; } |
| 13 |
|
| 14 |
template<int x> |
| 15 |
constexpr bool A<x>::far() { |
| 16 |
return requires(B b) { |
| 17 |
b.data_member; |
| 18 |
requires A<x-1>::far(); // #Invalid |
| 19 |
// expected-error@#Invalid {{recursive template instantiation exceeded maximum depth}} |
| 20 |
// expected-note@#Invalid 3 {{while}} |
| 21 |
// expected-note@#Invalid {{contexts in backtrace}} |
| 22 |
// expected-note@#Invalid {{use -ftemplate-depth=N to increase}} |
| 23 |
}; |
| 24 |
} |
| 25 |
static_assert(A<1>::far()); |
| 26 |
static_assert(!A<6>::far()); // expected-note {{in instantiation of member function}} |