2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / gcc.dg / c90-const-expr-8.c
blobb6aba7b1d87eab5ef03a2e553cbcdbc586158dcd
1 /* Test for constant expressions: overflow and constant expressions
2 with -fwrapv: overflows still count as such for the purposes of
3 constant expressions even when they have defined values at
4 runtime. */
5 /* Origin: Joseph Myers <joseph@codesourcery.com> */
6 /* { dg-do compile } */
7 /* { dg-options "-std=iso9899:1990 -pedantic-errors -fwrapv" } */
9 #include <limits.h>
11 enum e {
12 E0 = 0 * (INT_MAX + 1), /* { dg-warning "21:integer overflow in expression" } */
13 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 12 } */
14 E1 = 0 * (INT_MIN / -1), /* { dg-warning "21:integer overflow in expression" } */
15 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 14 } */
16 E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "21:integer overflow in expression" } */
17 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 16 } */
18 E3 = 0 * (INT_MIN - 1), /* { dg-warning "21:integer overflow in expression" } */
19 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 18 } */
20 E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "31:integer overflow in expression" } */
21 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 20 } */
22 E5 = 0 * -INT_MIN, /* { dg-warning "12:integer overflow in expression" } */
23 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 22 } */
24 E6 = 0 * !-INT_MIN, /* { dg-warning "13:integer overflow in expression" } */
25 /* { dg-error "8:not an integer constant" "constant" { target *-*-* } 24 } */
26 E7 = INT_MIN % -1 /* { dg-warning "16:integer overflow in expression" } */
27 /* { dg-error "1:overflow in constant expression" "constant" { target *-*-* } 28 } */