annotate gcc/testsuite/gcc.dg/c90-const-expr-7.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for constant expressions: overflow and constant expressions;
kono
parents:
diff changeset
2 see also overflow-warn-*.c for some other cases. */
kono
parents:
diff changeset
3 /* Origin: Joseph Myers <joseph@codesourcery.com> */
kono
parents:
diff changeset
4 /* { dg-do compile } */
kono
parents:
diff changeset
5 /* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 #include <float.h>
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 int a = DBL_MAX; /* { dg-warning "overflow in conversion" } */
kono
parents:
diff changeset
10 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
kono
parents:
diff changeset
11 int b = (int) DBL_MAX; /* { dg-error "overflow" } */
kono
parents:
diff changeset
12 unsigned int c = -1.0; /* { dg-warning "overflow in conversion" } */
kono
parents:
diff changeset
13 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
kono
parents:
diff changeset
14 unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 int e = 0 << 1000; /* { dg-warning "shift count" } */
kono
parents:
diff changeset
17 /* { dg-error "constant" "constant" { target *-*-* } .-1 } */
kono
parents:
diff changeset
18 int f = 0 << -1; /* { dg-warning "shift count" } */
kono
parents:
diff changeset
19 /* { dg-error "constant" "constant" { target *-*-* } .-1 } */
kono
parents:
diff changeset
20 int g = 0 >> 1000; /* { dg-warning "shift count" } */
kono
parents:
diff changeset
21 /* { dg-error "constant" "constant" { target *-*-* } .-1 } */
kono
parents:
diff changeset
22 int h = 0 >> -1; /* { dg-warning "shift count" } */
kono
parents:
diff changeset
23 /* { dg-error "constant" "constant" { target *-*-* } .-1 } */
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 int b1 = (0 ? (int) DBL_MAX : 0);
kono
parents:
diff changeset
26 unsigned int d1 = (0 ? (unsigned int)-1.0 : 0);
kono
parents:
diff changeset
27 int e1 = (0 ? 0 << 1000 : 0);
kono
parents:
diff changeset
28 int f1 = (0 ? 0 << -1 : 0);
kono
parents:
diff changeset
29 int g1 = (0 ? 0 >> 1000 : 0);
kono
parents:
diff changeset
30 int h1 = (0 ? 0 >> -1: 0);
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 int i = -1 << 0;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 int j[1] = { DBL_MAX }; /* { dg-warning "overflow in conversion" } */
kono
parents:
diff changeset
35 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */