2 /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
3 /* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
5 #define SCHAR_MAX __SCHAR_MAX__
6 #define SHRT_MAX __SHRT_MAX__
7 #define INT_MAX __INT_MAX__
8 #define INT_MIN (-__INT_MAX__ - 1)
10 void __attribute__((noinline
,noclone
))
20 #if __INT_MAX__ == 2147483647
21 /* Here, nothing should fail. */
22 volatile int j
= INT_MAX
;
24 volatile int k
= j
+ i
;
25 check (k
, 2147483646);
27 check (k
, 2147483646);
29 check (j
, 2147483646);
34 check (k
, -2147483647);
36 check (k
, -2147483647);
38 check (j
, -2147483647);
41 /* Test integer promotion. */
42 #if __SCHAR_MAX__ == 127
43 volatile signed char a
= SCHAR_MAX
;
44 volatile signed char b
= 1;
45 volatile signed char c
= a
+ b
;
51 #if __SHRT_MAX__ == 32767
52 volatile short d
= SHRT_MAX
;
54 volatile short f
= d
+ e
;