annotate gcc/testsuite/c-c++-common/pr48418.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* PR c/48418 */
kono
parents:
diff changeset
2 /* { dg-do compile } */
kono
parents:
diff changeset
3 /* { dg-options "-Wall -O2" } */
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 int
kono
parents:
diff changeset
6 foo (int x)
kono
parents:
diff changeset
7 {
kono
parents:
diff changeset
8 const int a = sizeof (int) * __CHAR_BIT__;
kono
parents:
diff changeset
9 const int b = -7;
kono
parents:
diff changeset
10 int c = 0;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
11 c += x << a; /* { dg-warning "10:left shift count >= width of type" } */
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
12 c += x << b; /* { dg-warning "10:left shift count is negative" } */
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
13 c += x << (sizeof (int) * __CHAR_BIT__); /* { dg-warning "10:left shift count >= width of type" } */
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
14 c += x << -7; /* { dg-warning "10:left shift count is negative" } */
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
15 c += x >> a; /* { dg-warning "10:right shift count >= width of type" } */
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
16 c += x >> b; /* { dg-warning "10:right shift count is negative" } */
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
17 c += x >> (sizeof (int) * __CHAR_BIT__); /* { dg-warning "10:right shift count >= width of type" } */
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
18 c += x >> -7; /* { dg-warning "10:right shift count is negative" } */
111
kono
parents:
diff changeset
19 return c;
kono
parents:
diff changeset
20 }