Wattributes-10.c: Add -fno-common option on hppa*-*-hpux*.
[official-gcc.git] / gcc / testsuite / c-c++-common / Wshift-negative-value-1.c
blob7df1804615d65fe8b109bf476a89588cea44025d
1 /* PR c/65179 */
2 /* { dg-do compile } */
3 /* { dg-options "-O -Wextra" } */
4 /* { dg-additional-options "-std=c++11" { target c++ } } */
6 enum E {
7 A = 0 << 1,
8 B = 1 << 1,
9 C = -1 << 1, /* { dg-warning "left shift of negative value|not an integer constant" } */
10 /* { dg-error "left operand of shift expression" "shift" { target c++ } .-1 } */
11 D = 0 >> 1,
12 E = 1 >> 1,
13 F = -1 >> 1
16 int
17 left (int x)
19 /* Warn for LSHIFT_EXPR. */
20 const int z = 0;
21 const int o = 1;
22 const int m = -1;
23 int r = 0;
24 r += z << x;
25 r += o << x;
26 r += m << x; /* { dg-warning "left shift of negative value" } */
27 r += 0 << x;
28 r += 1 << x;
29 r += -1 << x; /* { dg-warning "left shift of negative value" } */
30 r += -1U << x;
31 return r;
34 int
35 right (int x)
37 /* Shouldn't warn for RSHIFT_EXPR. */
38 const int z = 0;
39 const int o = 1;
40 const int m = -1;
41 int r = 0;
42 r += z >> x;
43 r += o >> x;
44 r += m >> x;
45 r += 0 >> x;
46 r += 1 >> x;
47 r += -1 >> x;
48 r += -1U >> x;
49 return r;