blob: d66c71ba548a301321084ac3366521996d1d44c5 [file] [log] [blame]
Richard Smithab91ef12012-07-08 02:38:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 512 -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 512}} \
7// expected-note 3 {{instantiation of default function argument}} \
8// expected-note {{skipping 509 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<256>;
18template struct S<512>;
19template struct S<768>;
20template struct S<1024>;
21template struct S<1280>;
22template struct S<1536>;
23template struct S<1792>;
24template struct S<2048>;
25
26// Check that we actually bail out when we hit the instantiation depth limit for
27// the default arguments.
28void g() { S<2048>::f(); } // expected-note {{required here}}