1 /* PR middle-end/88232 - Please implement -Winfinite-recursion
3 Explicit { dg-require-effective-target exceptions_enabled } to avoid verify compiler messages FAILs for '-fno-exceptions'.
4 { dg-options "-Wall -Winfinite-recursion" } */
6 typedef __SIZE_TYPE__ size_t;
11 /* Verify a warning is issued even though a call to f() might throw,
12 breaking the infinite recursion. */
14 void warn_f_call_r (int n) // { dg-warning "-Winfinite-recursion" }
18 warn_f_call_r (n - 1); // { dg-message "recursive call" }
21 void warn_f_do_while_call_r (int n) // { dg-warning "-Winfinite-recursion" }
27 warn_f_do_while_call_r (n - 1); // { dg-message "recursive call" }
39 /* Verify a warning even though the X ctor might throw, breaking
40 the recursion. Using possible throwing to suppress the warning
41 would make it pretty much useless in C++. */
43 int warn_class_with_ctor (int n) // { dg-warning "-Winfinite-recursion" }
46 return n + warn_class_with_ctor (n - 1);
50 int nowarn_throw (int n)
53 throw "argument too big";
55 return n + nowarn_throw (n - 1);
59 /* Verify call operator new doesn't suppress the warning even though
64 void warn_call_new (int i) // { dg-warning "-Winfinite-recursion" }
68 warn_call_new (i - 1);
71 /* Verify a recursive call to operator new. */
73 void* operator new[] (size_t n) // { dg-warning "-Winfinite-recursion" }
75 char *p = new char[n + sizeof (n)]; // { dg-message "recursive call" }