Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / c-c++-common / pr56607.c
1 /* PR c++/56607 */
2 /* { dg-do compile { target { { lp64 || ilp32 } || llp64 } } } */
3 /* { dg-options "-O2 -Wdiv-by-zero" } */
4
5 int
6 f1 (void)
7 {
8   return 1 / (sizeof (char) - 1);       /* { dg-warning "division by zero" } */
9 }
10
11 int
12 f2 (void)
13 {
14   const int x = sizeof (char) - 1;
15   return 1 / x;                         /* { dg-warning "division by zero" "" { target c++ } } */
16 }
17
18 int
19 f3 (void)
20 {
21   return 1 / (sizeof (int) / 3 - 1);    /* { dg-warning "division by zero" } */
22 }
23
24 int
25 f4 (void)
26 {
27   const int x = sizeof (int) / 3 - 1;
28   return 1 / x;                         /* { dg-warning "division by zero" "" { target c++ } } */
29 }