Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 512 -ftemplate-backtrace-limit 4 %s |
| 2 | |
NAKAMURA Takumi | fff457f | 2012-07-08 09:35:16 +0000 | [diff] [blame^] | 3 | // XFAIL: mingw32 |
| 4 | |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 5 | template<int N> struct S { |
| 6 | typedef typename S<N-1>::type type; |
| 7 | static int f(int n = S<N-1>::f()); // \ |
| 8 | // expected-error{{recursive template instantiation exceeded maximum depth of 512}} \ |
| 9 | // expected-note 3 {{instantiation of default function argument}} \ |
| 10 | // expected-note {{skipping 509 contexts in backtrace}} \ |
| 11 | // expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}} |
| 12 | |
| 13 | }; |
| 14 | template<> struct S<0> { |
| 15 | typedef int type; |
| 16 | }; |
| 17 | |
| 18 | // Incrementally instantiate up to S<2048>. |
| 19 | template struct S<256>; |
| 20 | template struct S<512>; |
| 21 | template struct S<768>; |
| 22 | template struct S<1024>; |
| 23 | template struct S<1280>; |
| 24 | template struct S<1536>; |
| 25 | template struct S<1792>; |
| 26 | template struct S<2048>; |
| 27 | |
| 28 | // Check that we actually bail out when we hit the instantiation depth limit for |
| 29 | // the default arguments. |
| 30 | void g() { S<2048>::f(); } // expected-note {{required here}} |