Fix type in the changelog entry,
[official-gcc.git] / gcc / testsuite / c-c++-common / Wshift-negative-value-2.c
blobfc89af1ba4bf28971dba1fe02eaf51094b46df29
1 /* PR c/65179 */
2 /* { dg-do compile } */
3 /* { dg-options "-O -Wshift-negative-value" } */
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" } */
10 D = 0 >> 1,
11 E = 1 >> 1,
12 F = -1 >> 1
15 int
16 left (int x)
18 /* Warn for LSHIFT_EXPR. */
19 const int z = 0;
20 const int o = 1;
21 const int m = -1;
22 int r = 0;
23 r += z << x;
24 r += o << x;
25 r += m << x; /* { dg-warning "left shift of negative value" } */
26 r += 0 << x;
27 r += 1 << x;
28 r += -1 << x; /* { dg-warning "left shift of negative value" } */
29 r += -1U << x;
30 return r;
33 int
34 right (int x)
36 /* Shouldn't warn for RSHIFT_EXPR. */
37 const int z = 0;
38 const int o = 1;
39 const int m = -1;
40 int r = 0;
41 r += z >> x;
42 r += o >> x;
43 r += m >> x;
44 r += 0 >> x;
45 r += 1 >> x;
46 r += -1 >> x;
47 r += -1U >> x;
48 return r;