Rebase.
[official-gcc.git] / gcc / testsuite / c-c++-common / ubsan / shift-1.c
blobd5c70baa815b2035917af5139ef1be49d6375d2a
1 /* { dg-do run } */
2 /* { dg-options "-fsanitize=shift -w" } */
4 typedef const unsigned long long int CULLI;
5 typedef volatile int VI;
6 struct s { signed long int a; };
8 int
9 main (void)
11 int a = 1;
12 struct s s = { .a = 400 };
13 CULLI culli = 42;
14 VI vi = 370;
15 volatile int shiftcount = 153;
17 a <<= 152;
18 1 << shiftcount;
19 1 << 154;
20 culli << 524;
21 1 << vi++;
22 (long) 1 << (s.a + 2);
24 return 0;
26 /* { dg-output "shift exponent 152 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
27 /* { dg-output "\[^\n\r]*shift exponent 153 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
28 /* { dg-output "\[^\n\r]*shift exponent 154 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
29 /* { dg-output "\[^\n\r]*shift exponent 524 is too large for \[^\n\r]*-bit type 'long long unsigned int'\[^\n\r]*(\n|\r\n|\r)" } */
30 /* { dg-output "\[^\n\r]*shift exponent 370 is too large for \[^\n\r]*-bit type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
31 /* { dg-output "\[^\n\r]*shift exponent 402 is too large for \[^\n\r]*-bit type 'long int'\[^\n\r]*" } */