Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 128 -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 | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 6 | // expected-error{{recursive template instantiation exceeded maximum depth of 128}} \ |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 7 | // expected-note 3 {{instantiation of default function argument}} \ |
Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 8 | // expected-note {{skipping 125 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>. |
Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 17 | template struct S<128>; |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 18 | template struct S<256>; |
Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 19 | template struct S<384>; |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 20 | template struct S<512>; |
Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 21 | template struct S<640>; |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 22 | template struct S<768>; |
Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 23 | template struct S<896>; |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 24 | template struct S<1024>; |
Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 25 | template struct S<1152>; |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 26 | template struct S<1280>; |
Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 27 | template struct S<1408>; |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 28 | template struct S<1536>; |
Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 29 | template struct S<1664>; |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 30 | template struct S<1792>; |
Richard Smith | f5baeb4 | 2012-07-15 23:29:50 +0000 | [diff] [blame] | 31 | template struct S<1920>; |
Richard Smith | ab91ef1 | 2012-07-08 02:38:24 +0000 | [diff] [blame] | 32 | template struct S<2048>; |
| 33 | |
| 34 | // Check that we actually bail out when we hit the instantiation depth limit for |
| 35 | // the default arguments. |
| 36 | void g() { S<2048>::f(); } // expected-note {{required here}} |