gcc/testsuite/g++.dg/warn/Winfinite-recursion.C
raw| 1 | /* PR middle-end/88232 - Please implement -Winfinite-recursion |
| 2 | { dg-do compile } |
| 3 | { dg-options "-Wall -Winfinite-recursion" } */ |
| 4 | |
| 5 | template <typename D> |
| 6 | struct C |
| 7 | { |
| 8 | void foo () // { dg-warning "-Winfinite-recursion" } |
| 9 | { |
| 10 | static_cast<D *>(this)->foo (); |
| 11 | } |
| 12 | }; |
| 13 | |
| 14 | struct D : C<D> |
| 15 | { |
| 16 | // this is missing: |
| 17 | // void foo() {} |
| 18 | }; |
| 19 | |
| 20 | void f (D *d) |
| 21 | { |
| 22 | d->foo (); |
| 23 | } |
| 24 | |
| 25 | |
| 26 | struct E : C<D> |
| 27 | { |
| 28 | void foo() {} |
| 29 | }; |
| 30 | |
| 31 | void g (E *e) |
| 32 | { |
| 33 | e->foo (); |
| 34 | } |