blob: 6032a33514a996aefa6f26c3ec578e3fe5668b2f [file] [log] [blame]
Richard Smith6ff6cfe2012-07-08 21:06:29 +00001// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 256 -ftemplate-backtrace-limit 4 %s
NAKAMURA Takumifff457f2012-07-08 09:35:16 +00002
Richard Smithab91ef12012-07-08 02:38:24 +00003template<int N> struct S {
4 typedef typename S<N-1>::type type;
5 static int f(int n = S<N-1>::f()); // \
Richard Smith6ff6cfe2012-07-08 21:06:29 +00006// expected-error{{recursive template instantiation exceeded maximum depth of 256}} \
Richard Smithab91ef12012-07-08 02:38:24 +00007// expected-note 3 {{instantiation of default function argument}} \
Richard Smith6ff6cfe2012-07-08 21:06:29 +00008// expected-note {{skipping 253 contexts in backtrace}} \
Richard Smithab91ef12012-07-08 02:38:24 +00009// 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}}