27 lines · cpp
1// RUN: %clang -fsyntax-only -std=c++2a -Xclang -verify -ftemplate-depth=5 -ftemplate-backtrace-limit=4 %s2 3// RequiresExpr contains invalid requirement. (Eg. Highly recursive template).4template<int x>5struct A { static constexpr bool far(); };6class B {7 bool data_member;8 friend struct A<1>;9};10 11template<>12constexpr bool A<0>::far() { return true; }13 14template<int x>15constexpr bool A<x>::far() {16 return requires(B b) {17 b.data_member;18 requires A<x-1>::far(); // #Invalid19 // 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}25static_assert(A<1>::far());26static_assert(!A<6>::far()); // expected-note {{in instantiation of member function}}27