PR lto/84212 - -Wno-* does not disable warnings from -flto link stage
[official-gcc.git] / gcc / testsuite / g++.dg / warn / Wdiv-by-zero-2.C
blob675e9594b8e41031ad95085b1b6d0a79ca143034
1 // PR c++/56607
2 // { dg-do compile { target { { lp64 || ilp32 } || llp64 } } }
3 // { dg-require-effective-target c++11 }
4 // { dg-options "-O2 -Wdiv-by-zero" }
6 constexpr int sc () { return sizeof (char); }
7 constexpr int si () { return sizeof (int); }
8 constexpr int zc () { return sc () - 1; }
9 constexpr int zi (int d) { return si () / d - 1; }
11 int
12 f1 (void)
14   return 1 / zc ();                     // { dg-warning "division by zero" }
17 int
18 f2 (void)
20   constexpr int x = zc ();
21   return 1 / x;                         // { dg-warning "division by zero" }
24 int
25 f3 (void)
27   return 1 / zi (3);                    // { dg-warning "division by zero" }
30 int
31 f4 (void)
33   constexpr int x = zi (3);
34   return 1 / x;                         // { dg-warning "division by zero" }