1 // RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 128 -ftemplate-backtrace-limit 4 %s
2 
3 template<int N> struct S {
4   typedef typename S<N-1>::type type;
5   static int f(int n = S<N-1>::f()); // \
6 // expected-error{{recursive template instantiation exceeded maximum depth of 128}} \
7 // expected-note 3 {{instantiation of default function argument}} \
8 // expected-note {{skipping 125 contexts in backtrace}} \
9 // expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}}
10 
11 };
12 template<> struct S<0> {
13   typedef int type;
14 };
15 
16 // Incrementally instantiate up to S<2048>.
17 template struct S<128>;
18 template struct S<256>;
19 template struct S<384>;
20 template struct S<512>;
21 template struct S<640>;
22 template struct S<768>;
23 template struct S<896>;
24 template struct S<1024>;
25 template struct S<1152>;
26 template struct S<1280>;
27 template struct S<1408>;
28 template struct S<1536>;
29 template struct S<1664>;
30 template struct S<1792>;
31 template struct S<1920>;
32 template struct S<2048>;
33 
34 // Check that we actually bail out when we hit the instantiation depth limit for
35 // the default arguments.
g()36 void g() { S<2048>::f(); } // expected-note {{required here}}
37