2018-05-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / c90-const-expr-8.c
blobc9e41541f2b84299cad04ce0d9951e1ecdefbe4b
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 *-*-* } .-1 } */
14 E1 = 0 * (INT_MIN / -1), /* { dg-warning "21:integer overflow in expression" } */
15 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */
16 E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "21:integer overflow in expression" } */
17 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */
18 E3 = 0 * (INT_MIN - 1), /* { dg-warning "21:integer overflow in expression" } */
19 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */
20 E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "31:integer overflow in expression" } */
21 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */
22 E5 = 0 * -INT_MIN, /* { dg-warning "12:integer overflow in expression" } */
23 /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } .-1 } */
24 E6 = 0 * !-INT_MIN, /* { dg-warning "13:integer overflow in expression" } */
25 /* { dg-error "8:not an integer constant" "constant" { target *-*-* } .-1 } */
26 E7 = INT_MIN % -1 /* { dg-warning "16:integer overflow in expression" } */
27 /* { dg-error "1:overflow in constant expression" "constant" { target *-*-* } .+1 } */