]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/builtin-arith-overflow-3.c
2 /* { dg-options "-O2" } */
6 #define LL_MIN ((long long)(-__LONG_LONG_MAX__ - 1))
8 #define SC1 (LL_MIN + 5)
9 #define UC1 ((1ULL << (__LONG_LONG_WIDTH__ - 1)) | 5ULL)
12 long long __attribute__ ((noinline
, noclone
))
16 if (__builtin_add_overflow (a
, SC1
, &x
)) cnt
++;
20 unsigned long long __attribute__ ((noinline
, noclone
))
21 f2 (unsigned long long a
)
24 if (__builtin_add_overflow (a
, UC1
, &x
))
31 if (f1 (-5) != LL_MIN
) __builtin_abort ();
32 if (cnt
!= 0) __builtin_abort ();
34 if (cnt
!= 1) __builtin_abort ();
36 if (f2 (UC2
) != ~0ULL) __builtin_abort ();
37 if (cnt
!= 0) __builtin_abort ();
38 if (f2 (UC2
+ 1) != 0) __builtin_abort ();
39 if (cnt
!= 1) __builtin_abort ();