diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index 3a571e0077bd37ee8e0209bfeb2794023ccb52aa..655ceb3d68301f14fd500b17e7cc682bac9d8ccb 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -7513,6 +7513,7 @@ static int flag_isoc94 = 0; static int flag_isoc99 = 0; static int flag_isoc11 = 0; static int flag_isoc23 = 0; +static int flag_isoc2y = 0; /* Install what the common builtins.def offers plus our local additions. diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def index 12f49e01de86700b85f2c31db8739ba28a3d9826..427af741c6b09d65240901b0ad4f857b3ad79e22 100644 --- a/gcc/builtin-types.def +++ b/gcc/builtin-types.def @@ -256,6 +256,7 @@ DEF_FUNCTION_TYPE_0 (BT_FN_DFLOAT64X, BT_DFLOAT64X) DEF_FUNCTION_TYPE_1 (BT_FN_LONG_LONG, BT_LONG, BT_LONG) DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_LONGLONG, BT_LONGLONG, BT_LONGLONG) +DEF_FUNCTION_TYPE_1 (BT_FN_UINTMAX_INTMAX, BT_UINTMAX, BT_INTMAX) DEF_FUNCTION_TYPE_1 (BT_FN_INTMAX_INTMAX, BT_INTMAX, BT_INTMAX) DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT_FLOAT, BT_FLOAT, BT_FLOAT) DEF_FUNCTION_TYPE_1 (BT_FN_DOUBLE_DOUBLE, BT_DOUBLE, BT_DOUBLE) @@ -403,7 +404,9 @@ DEF_FUNCTION_TYPE_1 (BT_FN_UINT_CONST_PTR, BT_UINT, BT_CONST_PTR) DEF_FUNCTION_TYPE_1 (BT_FN_ULONG_PTR, BT_ULONG, BT_PTR) DEF_FUNCTION_TYPE_1 (BT_FN_ULONG_CONST_PTR, BT_ULONG, BT_CONST_PTR) DEF_FUNCTION_TYPE_1 (BT_FN_ULONG_ULONG, BT_ULONG, BT_ULONG) +DEF_FUNCTION_TYPE_1 (BT_FN_ULONG_LONG, BT_ULONG, BT_LONG) DEF_FUNCTION_TYPE_1 (BT_FN_ULONGLONG_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG) +DEF_FUNCTION_TYPE_1 (BT_FN_ULONGLONG_LONGLONG, BT_ULONGLONG, BT_LONGLONG) DEF_FUNCTION_TYPE_1 (BT_FN_INT8_FLOAT, BT_INT8, BT_FLOAT) DEF_FUNCTION_TYPE_1 (BT_FN_INT16_FLOAT, BT_INT16, BT_FLOAT) DEF_FUNCTION_TYPE_1 (BT_FN_UINT32_FLOAT, BT_UINT32, BT_FLOAT) diff --git a/gcc/builtins.cc b/gcc/builtins.cc index ce92b368a3264c5c6f77580e60ca37a1a7e2bf51..029c561d46650143b10647ebd198acf41ddb3057 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -9378,7 +9378,8 @@ fold_builtin_fabs (location_t loc, tree arg, tree type) return fold_build1_loc (loc, ABS_EXPR, type, arg); } -/* Fold a call to abs, labs, llabs or imaxabs with argument ARG. */ +/* Fold a call to abs, labs, llabs, imaxabs, uabs, ulabs, ullabs or uimaxabs + with argument ARG. */ static tree fold_builtin_abs (location_t loc, tree arg, tree type) @@ -9386,6 +9387,14 @@ fold_builtin_abs (location_t loc, tree arg, tree type) if (!validate_arg (arg, INTEGER_TYPE)) return NULL_TREE; + if (TYPE_UNSIGNED (type)) + { + if (TYPE_PRECISION (TREE_TYPE (arg)) + != TYPE_PRECISION (type) + || TYPE_UNSIGNED (TREE_TYPE (arg))) + return NULL_TREE; + return fold_build1_loc (loc, ABSU_EXPR, type, arg); + } arg = fold_convert_loc (loc, type, arg); return fold_build1_loc (loc, ABS_EXPR, type, arg); } @@ -10518,6 +10527,10 @@ fold_builtin_1 (location_t loc, tree expr, tree fndecl, tree arg0) case BUILT_IN_LABS: case BUILT_IN_LLABS: case BUILT_IN_IMAXABS: + case BUILT_IN_UABS: + case BUILT_IN_ULABS: + case BUILT_IN_ULLABS: + case BUILT_IN_UIMAXABS: return fold_builtin_abs (loc, arg0, type); CASE_FLT_FN (BUILT_IN_CONJ): diff --git a/gcc/builtins.def b/gcc/builtins.def index 4c2f9be43bad491834a33af69ec81e0a59285992..fac6bc9ad164a8102d9b874dfa24a9c8dc180438 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -164,6 +164,14 @@ along with GCC; see the file COPYING3. If not see true, true, !flag_isoc23, ATTRS, \ targetm.libc_has_function (function_c23_misc, NULL_TREE), true) +/* Like DEF_LIB_BUILTIN, except that the function is only a part of + the standard in C2Y or above. */ +#undef DEF_C2Y_BUILTIN +#define DEF_C2Y_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ + DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ + true, true, !flag_isoc2y, ATTRS, \ + targetm.libc_has_function (function_c2y_misc, NULL_TREE), true) + /* Like DEF_C99_BUILTIN, but for complex math functions. */ #undef DEF_C99_COMPL_BUILTIN #define DEF_C99_COMPL_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ @@ -1073,6 +1081,10 @@ DEF_GCC_BUILTIN (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_RT_NOTHRO DEF_EXT_LIB_BUILTIN (BUILT_IN_STRFMON, "strfmon", BT_FN_SSIZE_STRING_SIZE_CONST_STRING_VAR, ATTR_FORMAT_STRFMON_NOTHROW_3_4) DEF_LIB_BUILTIN (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_TM_PTR, ATTR_FORMAT_STRFTIME_NOTHROW_3_0) DEF_GCC_BUILTIN (BUILT_IN_TRAP, "trap", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST) +DEF_C2Y_BUILTIN (BUILT_IN_UABS, "uabs", BT_FN_UINT_INT, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C2Y_BUILTIN (BUILT_IN_UIMAXABS, "uimaxabs", BT_FN_UINTMAX_INTMAX, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C2Y_BUILTIN (BUILT_IN_ULABS, "ulabs", BT_FN_ULONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST) +DEF_C2Y_BUILTIN (BUILT_IN_ULLABS, "ullabs", BT_FN_ULONGLONG_LONGLONG, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_GCC_BUILTIN (BUILT_IN_UNREACHABLE_TRAP, "unreachable trap", BT_FN_VOID, ATTR_CONST_NORETURN_NOTHROW_LEAF_COLD_LIST) DEF_GCC_BUILTIN (BUILT_IN_UNREACHABLE, "unreachable", BT_FN_VOID, ATTR_CONST_NORETURN_NOTHROW_LEAF_COLD_LIST) DEF_GCC_BUILTIN (BUILT_IN_UNWIND_INIT, "unwind_init", BT_FN_VOID, ATTR_NULL) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index ef5d1814f2ef70a1bd1093e8055f4901b8a179e2..e8ccba316342d6268fba2faef0e75de6e220d142 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -421,7 +421,8 @@ enum function_class { function_c99_math_complex, function_sincos, function_c11_misc, - function_c23_misc + function_c23_misc, + function_c2y_misc }; /* Enumerate visibility settings. This is deliberately ordered from most diff --git a/gcc/lto/lto-lang.cc b/gcc/lto/lto-lang.cc index 8176fc55e067330710ab78074b8a39de053a7010..372b496f3d7a64eb105ccda7d5b089b52de6931e 100644 --- a/gcc/lto/lto-lang.cc +++ b/gcc/lto/lto-lang.cc @@ -262,6 +262,7 @@ int flag_isoc94; int flag_isoc99; int flag_isoc11; int flag_isoc23; +int flag_isoc2y; /* Attribute handlers. */ diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c index 1e0857f734dc2580844d6b1dfbca4e9d5b155b55..ac21ca32a9f8707bf9c5d0fd4037e0a06a6aa6c6 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c @@ -7,6 +7,7 @@ extern void abort (void); #endif typedef __INTMAX_TYPE__ intmax_t; +typedef unsigned __INTMAX_TYPE__ uintmax_t; __attribute__ ((__noinline__)) int @@ -39,3 +40,35 @@ imaxabs (intmax_t x) ABORT_INSIDE_MAIN; return x < 0 ? -x : x; } + +__attribute__ ((__noinline__)) +unsigned int +uabs (int x) +{ + ABORT_INSIDE_MAIN; + return x < 0 ? -(unsigned int) x : x; +} + +__attribute__ ((__noinline__)) +unsigned long +ulabs (long x) +{ + ABORT_INSIDE_MAIN; + return x < 0 ? -(unsigned long) x : x; +} + +__attribute__ ((__noinline__)) +unsigned long long +ullabs (long long x) +{ + ABORT_INSIDE_MAIN; + return x < 0 ? -(unsigned long long) x : x; +} + +__attribute__ ((__noinline__)) +uintmax_t +uimaxabs (intmax_t x) +{ + ABORT_INSIDE_MAIN; + return x < 0 ? -(uintmax_t) x : x; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-1-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-1-lib.c new file mode 100644 index 0000000000000000000000000000000000000000..b4cb98fb6e8e9fb357f5d0178377461e6bc8e466 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-1-lib.c @@ -0,0 +1,22 @@ +extern void abort (void); +extern int abs_called; +extern int inside_main; + +/* The ulabs call should have been optimized, but the uabs call + shouldn't have been. */ + +unsigned int +uabs (int x) +{ + if (inside_main) + abs_called = 1; + return (x < 0 ? -(unsigned int) x : x); +} + +unsigned long +ulabs (long x) +{ + if (inside_main) + abort (); + return (x < 0 ? -(unsigned long) x : x); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-1.c b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-1.c new file mode 100644 index 0000000000000000000000000000000000000000..79f3adf54d27ad1ed5be46c1663d779611ffd4e9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-1.c @@ -0,0 +1,22 @@ +/* Test for -fno-builtin-FUNCTION. */ +/* Origin: Joseph Myers <jsm28@cam.ac.uk>. */ +/* GCC normally handles uabs and ulabs as built-in functions even without + optimization. So test that with -fno-builtin-uabs, ulabs is so handled + but uabs isn't. */ + +int abs_called = 0; + +extern unsigned int uabs (int); +extern unsigned long ulabs (long); +extern void abort (void); + +void +main_test (void) +{ + if (ulabs (0) != 0) + abort (); + if (uabs (0) != 0) + abort (); + if (!abs_called) + abort (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-1.x b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-1.x new file mode 100644 index 0000000000000000000000000000000000000000..f1975e680946c60cf571f42247a865c5a04cd478 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-1.x @@ -0,0 +1,2 @@ +set additional_flags "-fno-builtin-uabs -std=c2y" +return 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-2-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-2-lib.c new file mode 100644 index 0000000000000000000000000000000000000000..494e5390e634d64849e1c4cef710eb5a8f0b36fd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-2-lib.c @@ -0,0 +1 @@ +#include "lib/abs.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-2.c b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-2.c new file mode 100644 index 0000000000000000000000000000000000000000..0eab0b492211f67f01f38c296a152905850aceca --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-2.c @@ -0,0 +1,123 @@ +/* Test for builtin uabs, ulabs, ullabs, uimaxabs. */ +/* Origin: Joseph Myers <jsm28@cam.ac.uk> */ + +#include <limits.h> +typedef __INTMAX_TYPE__ intmax_t; +typedef unsigned __INTMAX_TYPE__ uintmax_t; +#define INTMAX_MAX __INTMAX_MAX__ + +extern unsigned int uabs (int); +extern unsigned long ulabs (long); +extern unsigned long long ullabs (long long); +extern uintmax_t uimaxabs (intmax_t); +extern void abort (void); +extern void link_error (void); + +void +main_test (void) +{ + /* For each type, test both runtime and compile time (constant folding) + optimization. */ + volatile int i0 = 0, i1 = 1, im1 = -1, imin = -INT_MAX, imax = INT_MAX; + volatile long l0 = 0L, l1 = 1L, lm1 = -1L, lmin = -LONG_MAX, lmax = LONG_MAX; + volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL; + volatile long long llmin = -__LONG_LONG_MAX__, llmax = __LONG_LONG_MAX__; + volatile intmax_t imax0 = 0, imax1 = 1, imaxm1 = -1; + volatile intmax_t imaxmin = -INTMAX_MAX, imaxmax = INTMAX_MAX; + if (uabs (i0) != 0) + abort (); + if (uabs (0) != 0) + link_error (); + if (uabs (i1) != 1) + abort (); + if (uabs (1) != 1) + link_error (); + if (uabs (im1) != 1) + abort (); + if (uabs (-1) != 1) + link_error (); + if (uabs (imin) != INT_MAX) + abort (); + if (uabs (imin - 1) != 1U + INT_MAX) + abort (); + if (uabs (-INT_MAX) != INT_MAX) + link_error (); + if (uabs (-INT_MAX - 1) != 1U + INT_MAX) + link_error (); + if (uabs (imax) != INT_MAX) + abort (); + if (uabs (INT_MAX) != INT_MAX) + link_error (); + if (ulabs (l0) != 0L) + abort (); + if (ulabs (0L) != 0L) + link_error (); + if (ulabs (l1) != 1L) + abort (); + if (ulabs (1L) != 1L) + link_error (); + if (ulabs (lm1) != 1L) + abort (); + if (ulabs (-1L) != 1L) + link_error (); + if (ulabs (lmin) != LONG_MAX) + abort (); + if (ulabs (lmin - 1) != 1UL + LONG_MAX) + abort (); + if (ulabs (-LONG_MAX) != LONG_MAX) + link_error (); + if (ulabs (-LONG_MAX - 1) != 1UL + LONG_MAX) + link_error (); + if (ulabs (lmax) != LONG_MAX) + abort (); + if (ulabs (LONG_MAX) != LONG_MAX) + link_error (); + if (ullabs (ll0) != 0LL) + abort (); + if (ullabs (0LL) != 0LL) + link_error (); + if (ullabs (ll1) != 1LL) + abort (); + if (ullabs (1LL) != 1LL) + link_error (); + if (ullabs (llm1) != 1LL) + abort (); + if (ullabs (-1LL) != 1LL) + link_error (); + if (ullabs (llmin) != __LONG_LONG_MAX__) + abort (); + if (ullabs (llmin - 1) != 1ULL + __LONG_LONG_MAX__) + abort (); + if (ullabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__) + link_error (); + if (ullabs (-__LONG_LONG_MAX__ - 1) != 1ULL + __LONG_LONG_MAX__) + link_error (); + if (ullabs (llmax) != __LONG_LONG_MAX__) + abort (); + if (ullabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__) + link_error (); + if (uimaxabs (imax0) != 0) + abort (); + if (uimaxabs (0) != 0) + link_error (); + if (uimaxabs (imax1) != 1) + abort (); + if (uimaxabs (1) != 1) + link_error (); + if (uimaxabs (imaxm1) != 1) + abort (); + if (uimaxabs (-1) != 1) + link_error (); + if (uimaxabs (imaxmin) != INTMAX_MAX) + abort (); + if (uimaxabs (imaxmin - 1) != (uintmax_t) 1 + INTMAX_MAX) + abort (); + if (uimaxabs (-INTMAX_MAX) != INTMAX_MAX) + link_error (); + if (uimaxabs (-INTMAX_MAX - 1) != (uintmax_t) 1 + INTMAX_MAX) + link_error (); + if (uimaxabs (imaxmax) != INTMAX_MAX) + abort (); + if (uimaxabs (INTMAX_MAX) != INTMAX_MAX) + link_error (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-2.x b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-2.x new file mode 100644 index 0000000000000000000000000000000000000000..2a3ab2398cb55469770ec276ecb6742e29d96df7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-2.x @@ -0,0 +1,2 @@ +set additional_flags -std=c2y +return 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-3-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-3-lib.c new file mode 100644 index 0000000000000000000000000000000000000000..494e5390e634d64849e1c4cef710eb5a8f0b36fd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-3-lib.c @@ -0,0 +1 @@ +#include "lib/abs.c" diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-3.c b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-3.c new file mode 100644 index 0000000000000000000000000000000000000000..b45045cd45465bcc4a705a20042563fb78fdd104 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-3.c @@ -0,0 +1,119 @@ +/* Test for builtin uabs, ulabs, ullabs, uimaxabs. Test for __builtin versions. */ +/* Origin: Joseph Myers <jsm28@cam.ac.uk> */ + +#include <limits.h> +typedef __INTMAX_TYPE__ intmax_t; +typedef unsigned __INTMAX_TYPE__ uintmax_t; +#define INTMAX_MAX __INTMAX_MAX__ + +extern void abort (void); +extern void link_error (void); + +void +main_test (void) +{ + /* For each type, test both runtime and compile time (constant folding) + optimization. */ + volatile int i0 = 0, i1 = 1, im1 = -1, imin = -INT_MAX, imax = INT_MAX; + volatile long l0 = 0L, l1 = 1L, lm1 = -1L, lmin = -LONG_MAX, lmax = LONG_MAX; + volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL; + volatile long long llmin = -__LONG_LONG_MAX__, llmax = __LONG_LONG_MAX__; + volatile intmax_t imax0 = 0, imax1 = 1, imaxm1 = -1; + volatile intmax_t imaxmin = -INTMAX_MAX, imaxmax = INTMAX_MAX; + if (__builtin_uabs (i0) != 0) + abort (); + if (__builtin_uabs (0) != 0) + link_error (); + if (__builtin_uabs (i1) != 1) + abort (); + if (__builtin_uabs (1) != 1) + link_error (); + if (__builtin_uabs (im1) != 1) + abort (); + if (__builtin_uabs (-1) != 1) + link_error (); + if (__builtin_uabs (imin) != INT_MAX) + abort (); + if (__builtin_uabs (imin - 1) != 1U + INT_MAX) + abort (); + if (__builtin_uabs (-INT_MAX) != INT_MAX) + link_error (); + if (__builtin_uabs (-INT_MAX - 1) != 1U + INT_MAX) + link_error (); + if (__builtin_uabs (imax) != INT_MAX) + abort (); + if (__builtin_uabs (INT_MAX) != INT_MAX) + link_error (); + if (__builtin_ulabs (l0) != 0L) + abort (); + if (__builtin_ulabs (0L) != 0L) + link_error (); + if (__builtin_ulabs (l1) != 1L) + abort (); + if (__builtin_ulabs (1L) != 1L) + link_error (); + if (__builtin_ulabs (lm1) != 1L) + abort (); + if (__builtin_ulabs (-1L) != 1L) + link_error (); + if (__builtin_ulabs (lmin) != LONG_MAX) + abort (); + if (__builtin_ulabs (lmin - 1) != 1UL + LONG_MAX) + abort (); + if (__builtin_ulabs (-LONG_MAX) != LONG_MAX) + link_error (); + if (__builtin_ulabs (-LONG_MAX - 1) != 1UL + LONG_MAX) + link_error (); + if (__builtin_ulabs (lmax) != LONG_MAX) + abort (); + if (__builtin_ulabs (LONG_MAX) != LONG_MAX) + link_error (); + if (__builtin_ullabs (ll0) != 0LL) + abort (); + if (__builtin_ullabs (0LL) != 0LL) + link_error (); + if (__builtin_ullabs (ll1) != 1LL) + abort (); + if (__builtin_ullabs (1LL) != 1LL) + link_error (); + if (__builtin_ullabs (llm1) != 1LL) + abort (); + if (__builtin_ullabs (-1LL) != 1LL) + link_error (); + if (__builtin_ullabs (llmin) != __LONG_LONG_MAX__) + abort (); + if (__builtin_ullabs (llmin - 1) != 1ULL + __LONG_LONG_MAX__) + abort (); + if (__builtin_ullabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__) + link_error (); + if (__builtin_ullabs (-__LONG_LONG_MAX__ - 1) != 1ULL + __LONG_LONG_MAX__) + link_error (); + if (__builtin_ullabs (llmax) != __LONG_LONG_MAX__) + abort (); + if (__builtin_ullabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__) + link_error (); + if (__builtin_uimaxabs (imax0) != 0) + abort (); + if (__builtin_uimaxabs (0) != 0) + link_error (); + if (__builtin_uimaxabs (imax1) != 1) + abort (); + if (__builtin_uimaxabs (1) != 1) + link_error (); + if (__builtin_uimaxabs (imaxm1) != 1) + abort (); + if (__builtin_uimaxabs (-1) != 1) + link_error (); + if (__builtin_uimaxabs (imaxmin) != INTMAX_MAX) + abort (); + if (__builtin_uimaxabs (imaxmin - 1) != (uintmax_t) 1 + INTMAX_MAX) + abort (); + if (__builtin_uimaxabs (-INTMAX_MAX) != INTMAX_MAX) + link_error (); + if (__builtin_uimaxabs (-INTMAX_MAX - 1) != (uintmax_t) 1 + INTMAX_MAX) + link_error (); + if (__builtin_uimaxabs (imaxmax) != INTMAX_MAX) + abort (); + if (__builtin_uimaxabs (INTMAX_MAX) != INTMAX_MAX) + link_error (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-3.x b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-3.x new file mode 100644 index 0000000000000000000000000000000000000000..2a3ab2398cb55469770ec276ecb6742e29d96df7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/uabs-3.x @@ -0,0 +1,2 @@ +set additional_flags -std=c2y +return 0