1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 128 -ftemplate-backtrace-limit 4 %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc template<int N> struct S { 4*f4a2713aSLionel Sambuc typedef typename S<N-1>::type type; 5*f4a2713aSLionel Sambuc static int f(int n = S<N-1>::f()); // \ 6*f4a2713aSLionel Sambuc // expected-error{{recursive template instantiation exceeded maximum depth of 128}} \ 7*f4a2713aSLionel Sambuc // expected-note 3 {{instantiation of default function argument}} \ 8*f4a2713aSLionel Sambuc // expected-note {{skipping 125 contexts in backtrace}} \ 9*f4a2713aSLionel Sambuc // expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}} 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc }; 12*f4a2713aSLionel Sambuc template<> struct S<0> { 13*f4a2713aSLionel Sambuc typedef int type; 14*f4a2713aSLionel Sambuc }; 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc // Incrementally instantiate up to S<2048>. 17*f4a2713aSLionel Sambuc template struct S<128>; 18*f4a2713aSLionel Sambuc template struct S<256>; 19*f4a2713aSLionel Sambuc template struct S<384>; 20*f4a2713aSLionel Sambuc template struct S<512>; 21*f4a2713aSLionel Sambuc template struct S<640>; 22*f4a2713aSLionel Sambuc template struct S<768>; 23*f4a2713aSLionel Sambuc template struct S<896>; 24*f4a2713aSLionel Sambuc template struct S<1024>; 25*f4a2713aSLionel Sambuc template struct S<1152>; 26*f4a2713aSLionel Sambuc template struct S<1280>; 27*f4a2713aSLionel Sambuc template struct S<1408>; 28*f4a2713aSLionel Sambuc template struct S<1536>; 29*f4a2713aSLionel Sambuc template struct S<1664>; 30*f4a2713aSLionel Sambuc template struct S<1792>; 31*f4a2713aSLionel Sambuc template struct S<1920>; 32*f4a2713aSLionel Sambuc template struct S<2048>; 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc // Check that we actually bail out when we hit the instantiation depth limit for 35*f4a2713aSLionel Sambuc // the default arguments. g()36*f4a2713aSLionel Sambucvoid g() { S<2048>::f(); } // expected-note {{required here}} 37