Merged r156806 through r156977 into branch.
[official-gcc.git] / gcc / testsuite / g++.dg / template / recurse.C
blob17fe1866eb2098bacaa75dabfe5a54a8d6643f62
1 // Test for handling of excessive template recursion.
2 // { dg-options "-ftemplate-depth-50 -O" }
4 template <int I> struct F
6   int operator()()
7     {
8       F<I+1> f;                 // { dg-error "incomplete type" "incomplete" }
9                                 // { dg-bogus "exceeds maximum.*exceeds maximum" "exceeds" { xfail *-*-* } 8 }
10                                 // { dg-error "exceeds maximum" "exceeds" { xfail *-*-* } 8 }
11       return f()*I;             // { dg-message "instantiated" "recurse" }
12       // { dg-message "skipping 40 instantiation contexts" "" { target *-*-* } 11 }
13     }
16 template <> struct F<52>
18   int operator()() { return 0; }
21 int main ()
23   F<1> f;
24   return f();           // { dg-message "instantiated from here" "excessive recursion" }
27 // Ignore excess messages from recursion.
28 // { dg-prune-output "instantiated from 'int" }