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