decl.c (grok_ctor_properties): Use DECL_SOURCE_LOCATION.
[official-gcc.git] / gcc / testsuite / c-c++-common / Wshift-negative-value-2.c
blob9f435e8958d0a5a1d2c9dd946fe3b47d2f3418f8
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 "10:left shift of negative value" } */
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-warning "10:left shift of negative value" } */
28 r += 0 << x;
29 r += 1 << x;
30 r += -1 << x; /* { dg-warning "11: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;