1// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 128 -ftemplate-backtrace-limit 4 %s
2
3template<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};
12template<> struct S<0> {
13  typedef int type;
14};
15
16// Incrementally instantiate up to S<2048>.
17template struct S<128>;
18template struct S<256>;
19template struct S<384>;
20template struct S<512>;
21template struct S<640>;
22template struct S<768>;
23template struct S<896>;
24template struct S<1024>;
25template struct S<1152>;
26template struct S<1280>;
27template struct S<1408>;
28template struct S<1536>;
29template struct S<1664>;
30template struct S<1792>;
31template struct S<1920>;
32template struct S<2048>;
33
34// Check that we actually bail out when we hit the instantiation depth limit for
35// the default arguments.
36void g() { S<2048>::f(); } // expected-note {{required here}}
37