Replace absolute line numbers in c-c++-common
[official-gcc.git] / gcc / testsuite / c-c++-common / Wshift-negative-value-3.c
blob503ca61eb6139eb6160f084987c7903496c78c4c
1 /* PR c/65179 */
2 /* { dg-do compile } */
3 /* { dg-options "-O -Wextra -Wno-shift-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,
10 /* { dg-error "not an integer constant" "no constant" { target c++ } .-1 } */
11 /* { dg-error "left operand of shift expression" "shift" { target c++ } .-2 } */
12 D = 0 >> 1,
13 E = 1 >> 1,
14 F = -1 >> 1
17 int
18 left (int x)
20 /* Warn for LSHIFT_EXPR. */
21 const int z = 0;
22 const int o = 1;
23 const int m = -1;
24 int r = 0;
25 r += z << x;
26 r += o << x;
27 r += m << x; /* { dg-bogus "left shift of negative value" } */
28 r += 0 << x;
29 r += 1 << x;
30 r += -1 << x; /* { dg-bogus "left shift of negative value" } */
31 r += -1U << x;
32 return r;
35 int
36 right (int x)
38 /* Shouldn't warn for RSHIFT_EXPR. */
39 const int z = 0;
40 const int o = 1;
41 const int m = -1;
42 int r = 0;
43 r += z >> x;
44 r += o >> x;
45 r += m >> x;
46 r += 0 >> x;
47 r += 1 >> x;
48 r += -1 >> x;
49 r += -1U >> x;
50 return r;