testsuite: Skip analyzer tests on AIX.
[official-gcc.git] / gcc / testsuite / c-c++-common / Wshift-overflow-1.c
blobbe5535f7c23a0b9066c288ad7c3618a2ffcb31a2
1 /* PR c++/55095 */
2 /* { dg-do compile { target int32 } } */
3 /* { dg-options "-O" } */
5 #define INTM1 (sizeof (int) * __CHAR_BIT__ - 1)
6 #define INTM2 (sizeof (int) * __CHAR_BIT__ - 2)
7 #define LLONGM1 (sizeof (long long) * __CHAR_BIT__ - 1)
8 #define LLONGM2 (sizeof (long long) * __CHAR_BIT__ - 2)
10 #define INT_MIN (-__INT_MAX__-1)
11 #define LONG_LONG_MIN (-__LONG_LONG_MAX__-1)
13 int i1 = 1 << INTM1;
14 int i2 = 9 << INTM1; /* { dg-warning "requires 36 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
15 int i3 = 10 << INTM2; /* { dg-warning "requires 35 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
16 int i4 = __INT_MAX__ << 2; /* { dg-warning "requires 34 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
17 int i5 = __INT_MAX__ << INTM1; /* { dg-warning "requires 63 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
18 int i6 = -1 << INTM1;
19 int i7 = -9 << INTM1; /* { dg-warning "requires 36 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
20 int i8 = -10 << INTM2; /* { dg-warning "requires 35 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
21 int i9 = -__INT_MAX__ << 2; /* { dg-warning "requires 34 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
22 int i10 = -__INT_MAX__ << INTM1; /* { dg-warning "requires 63 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
23 int i11 = INT_MIN << 1; /* { dg-warning "requires 33 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
25 int r1 = 1 >> INTM1;
26 int r2 = 9 >> INTM1;
27 int r3 = 10 >> INTM2;
28 int r4 = __INT_MAX__ >> 2;
29 int r5 = __INT_MAX__ >> INTM1;
30 int r6 = -1 >> INTM1;
31 int r7 = -9 >> INTM1;
32 int r8 = -10 >> INTM2;
33 int r9 = -__INT_MAX__ >> 2;
34 int r10 = -__INT_MAX__ >> INTM1;
36 unsigned u1 = 1 << INTM1;
37 unsigned u2 = 9 << INTM1; /* { dg-warning "requires 36 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
38 unsigned u3 = 2U << INTM1;
39 unsigned u4 = 9U << INTM1;
40 unsigned u5 = 10U << INTM2;
42 long long int l1 = 1LL << LLONGM1;
43 long long int l2 = 9LL << LLONGM1; /* { dg-warning "requires 68 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
44 long long int l3 = 10LL << LLONGM2; /* { dg-warning "requires 67 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
45 long long int l4 = __LONG_LONG_MAX__ << 2; /* { dg-warning "requires 66 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
46 long long int l5 = __LONG_LONG_MAX__ << LLONGM1; /* { dg-warning "requires 127 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
47 long long int l6 = -1LL << LLONGM1;
48 long long int l7 = -9LL << LLONGM1; /* { dg-warning "requires 68 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
49 long long int l8 = -10LL << LLONGM2; /* { dg-warning "requires 67 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
50 long long int l9 = -__LONG_LONG_MAX__ << 2; /* { dg-warning "requires 66 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
51 long long int l10 = -__LONG_LONG_MAX__ << LLONGM1; /* { dg-warning "requires 127 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
52 long long int l11 = LONG_LONG_MIN << 1; /* { dg-warning "requires 65 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
54 void
55 fn (void)
57 const int a = 10;
58 const __SIZE_TYPE__ b = INTM1;
59 int k1 = a << b; /* { dg-warning "requires 36 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
60 int k2 = 10 << b; /* { dg-warning "requires 36 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */
61 int k3 = a << INTM1; /* { dg-warning "requires 36 bits to represent" "" { target { c || { c++11 && c++17_down } } } } */