xref: /aosp_15_r20/external/clang/test/SemaTemplate/instantiation-depth.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 5 -ftemplate-backtrace-limit 4 %s
2*67e74705SXin Li // RUN: %clang -fsyntax-only -Xclang -verify -ftemplate-depth-5 -ftemplate-backtrace-limit=4 %s
3*67e74705SXin Li // RUN: %clang -fsyntax-only -Xclang -verify -ftemplate-depth=5 -ftemplate-backtrace-limit=4 %s
4*67e74705SXin Li 
5*67e74705SXin Li #ifndef NOEXCEPT
6*67e74705SXin Li 
7*67e74705SXin Li template<typename T> struct X : X<T*> { }; \
8*67e74705SXin Li // expected-error{{recursive template instantiation exceeded maximum depth of 5}} \
9*67e74705SXin Li // expected-note 3 {{instantiation of template class}} \
10*67e74705SXin Li // expected-note {{skipping 2 contexts in backtrace}} \
11*67e74705SXin Li // expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}}
12*67e74705SXin Li 
test()13*67e74705SXin Li void test() {
14*67e74705SXin Li   (void)sizeof(X<int>); // expected-note {{instantiation of template class}}
15*67e74705SXin Li }
16*67e74705SXin Li 
17*67e74705SXin Li #else
18*67e74705SXin Li 
19*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 5 -ftemplate-backtrace-limit 4 -std=c++11 -DNOEXCEPT %s
20*67e74705SXin Li 
21*67e74705SXin Li template<typename T> struct S {
22*67e74705SXin Li   S() noexcept(noexcept(T()));
23*67e74705SXin Li };
24*67e74705SXin Li struct T : S<T> {}; \
25*67e74705SXin Li // expected-error{{recursive template instantiation exceeded maximum depth of 5}} \
26*67e74705SXin Li // expected-note 4 {{in instantiation of exception spec}} \
27*67e74705SXin Li // expected-note {{skipping 2 contexts in backtrace}} \
28*67e74705SXin Li // expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}}
29*67e74705SXin Li T t; // expected-note {{implicit default constructor for 'T' first required here}}
30*67e74705SXin Li 
31*67e74705SXin Li #endif
32