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