blob: 6550987de784a0225a697f8002db315eb16b537d [file] [log] [blame]
Richard Smithf5baeb42012-07-15 23:29:50 +00001// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 128 -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 Smithf5baeb42012-07-15 23:29:50 +00006// expected-error{{recursive template instantiation exceeded maximum depth of 128}} \
Richard Smithab91ef12012-07-08 02:38:24 +00007// expected-note 3 {{instantiation of default function argument}} \
Richard Smithf5baeb42012-07-15 23:29:50 +00008// expected-note {{skipping 125 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>.
Richard Smithf5baeb42012-07-15 23:29:50 +000017template struct S<128>;
Richard Smithab91ef12012-07-08 02:38:24 +000018template struct S<256>;
Richard Smithf5baeb42012-07-15 23:29:50 +000019template struct S<384>;
Richard Smithab91ef12012-07-08 02:38:24 +000020template struct S<512>;
Richard Smithf5baeb42012-07-15 23:29:50 +000021template struct S<640>;
Richard Smithab91ef12012-07-08 02:38:24 +000022template struct S<768>;
Richard Smithf5baeb42012-07-15 23:29:50 +000023template struct S<896>;
Richard Smithab91ef12012-07-08 02:38:24 +000024template struct S<1024>;
Richard Smithf5baeb42012-07-15 23:29:50 +000025template struct S<1152>;
Richard Smithab91ef12012-07-08 02:38:24 +000026template struct S<1280>;
Richard Smithf5baeb42012-07-15 23:29:50 +000027template struct S<1408>;
Richard Smithab91ef12012-07-08 02:38:24 +000028template struct S<1536>;
Richard Smithf5baeb42012-07-15 23:29:50 +000029template struct S<1664>;
Richard Smithab91ef12012-07-08 02:38:24 +000030template struct S<1792>;
Richard Smithf5baeb42012-07-15 23:29:50 +000031template struct S<1920>;
Richard Smithab91ef12012-07-08 02:38:24 +000032template 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}}