This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Some of the newly (in 3.4) introduced builtin functions were documented to have unsigned arguments (and only this makes sense for them), but internally their prototypes were using signed arguments (causing ill warnings with -Wconversion). Additionally, intmax_t variants of them were missing. bootstrapped and tested on x86_64-unknown-linux-gnu. 2004-07-07 Jan Beulich <jbeulich@novell.com> * builtin-types.def (BT_UINT): Rename from BT_UNSIGNED. (BT_FN_UINT): Rename from BT_FN_UNSIGNED. (BT_FN_PTR_UINT): Rename from BT_FN_PTR_UNSIGNED. (BT_ULONG, BT_ULONGLONG, BT_UINTMAX, BT_FN_INT_UINT, BT_FN_INT_ULONG, BT_FN_INT_ULONGLONG, BT_FN_INT_INTMAX, BT_FN_INT_UINTMAX): New. * builtins.def (BUILTIN_CLZxxx, BUILTIN_CTXxxx, BUILTIN_PARITYxxx, BUILTIN_POPCOUNTxxx): Arguments are unsigned. (BUILTIN_xxxIMAX): New. * builtins.c (expand_builtin): Handle BUILT_IN_FFSIMAX, BUILT_IN_CLZIMAX, BUILT_IN_CTZIMAX, BUILT_IN_POPCOUNIMAX, and BUILT_IN_PARITYIMAX. testsuite: 2004-07-07 Jan Beulich <jbeulich@novell.com> * gcc.c-torture/execute/builtin-bitops-2.c: Enhanced version of gcc.c-torture/execute/builtin-bitops-1.c, namely to also test the imax variants of the respective builtins. * gcc.dg/builtin-protos-1.c: New test to check signedness of arguments of builtins. --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/builtins.c 2004-07-02 15:13:10.000000000 +0200 +++ 2004-07-05.10.09/gcc/builtins.c 2004-07-06 16:47:41.831975872 +0200 @@ -5862,6 +5862,7 @@ case BUILT_IN_FFS: case BUILT_IN_FFSL: case BUILT_IN_FFSLL: + case BUILT_IN_FFSIMAX: target = expand_builtin_unop (target_mode, arglist, target, subtarget, ffs_optab); if (target) @@ -5871,6 +5872,7 @@ case BUILT_IN_CLZ: case BUILT_IN_CLZL: case BUILT_IN_CLZLL: + case BUILT_IN_CLZIMAX: target = expand_builtin_unop (target_mode, arglist, target, subtarget, clz_optab); if (target) @@ -5880,6 +5882,7 @@ case BUILT_IN_CTZ: case BUILT_IN_CTZL: case BUILT_IN_CTZLL: + case BUILT_IN_CTZIMAX: target = expand_builtin_unop (target_mode, arglist, target, subtarget, ctz_optab); if (target) @@ -5889,6 +5892,7 @@ case BUILT_IN_POPCOUNT: case BUILT_IN_POPCOUNTL: case BUILT_IN_POPCOUNTLL: + case BUILT_IN_POPCOUNTIMAX: target = expand_builtin_unop (target_mode, arglist, target, subtarget, popcount_optab); if (target) @@ -5898,6 +5902,7 @@ case BUILT_IN_PARITY: case BUILT_IN_PARITYL: case BUILT_IN_PARITYLL: + case BUILT_IN_PARITYIMAX: target = expand_builtin_unop (target_mode, arglist, target, subtarget, parity_optab); if (target) --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/builtins.def 2004-07-02 15:13:10.000000000 +0200 +++ 2004-07-05.10.09/gcc/builtins.def 2004-07-06 17:01:11.455894328 +0200 @@ -444,9 +444,6 @@ DEF_EXT_LIB_BUILTIN (BUILT_IN_BCMP, "bcmp", BT_FN_INT_CONST_PTR_CONST_PTR_SIZE, ATTR_PURE_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN_BCOPY, "bcopy", BT_FN_VOID_CONST_PTR_PTR_SIZE, ATTR_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN_BZERO, "bzero", BT_FN_VOID_PTR_SIZE, ATTR_NOTHROW_LIST) -DEF_EXT_LIB_BUILTIN (BUILT_IN_FFS, "ffs", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST) -DEF_EXT_LIB_BUILTIN (BUILT_IN_FFSL, "ffsl", BT_FN_INT_LONG, ATTR_CONST_NOTHROW_LIST) -DEF_EXT_LIB_BUILTIN (BUILT_IN_FFSLL, "ffsll", BT_FN_INT_LONGLONG, ATTR_CONST_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN_INDEX, "index", BT_FN_STRING_CONST_STRING_INT, ATTR_PURE_NOTHROW_NONNULL_1) DEF_LIB_BUILTIN (BUILT_IN_MEMCMP, "memcmp", BT_FN_INT_CONST_PTR_CONST_PTR_SIZE, ATTR_PURE_NOTHROW_NONNULL_1_2) DEF_LIB_BUILTIN (BUILT_IN_MEMCPY, "memcpy", BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_NOTHROW_NONNULL_1_2) @@ -542,17 +539,19 @@ DEF_GCC_BUILTIN (BUILT_IN_ARGS_INFO, "args_info", BT_FN_INT_INT, ATTR_NULL) DEF_LIB_BUILTIN (BUILT_IN_CALLOC, "calloc", BT_FN_PTR_SIZE_SIZE, ATTR_MALLOC_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_CLASSIFY_TYPE, "classify_type", BT_FN_INT_VAR, ATTR_NULL) -DEF_GCC_BUILTIN (BUILT_IN_CLZ, "clz", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_CLZL, "clzl", BT_FN_INT_LONG, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_CLZLL, "clzll", BT_FN_INT_LONGLONG, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_CLZ, "clz", BT_FN_INT_UINT, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_CLZIMAX, "clzimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_CLZL, "clzl", BT_FN_INT_ULONG, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_CLZLL, "clzll", BT_FN_INT_ULONGLONG, ATTR_CONST_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_CONSTANT_P, "constant_p", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_CTZ, "ctz", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_CTZL, "ctzl", BT_FN_INT_LONG, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_CTZLL, "ctzll", BT_FN_INT_LONGLONG, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_CTZ, "ctz", BT_FN_INT_UINT, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_CTZIMAX, "ctzimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_CTZL, "ctzl", BT_FN_INT_ULONG, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_CTZLL, "ctzll", BT_FN_INT_ULONGLONG, ATTR_CONST_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN_DCGETTEXT, "dcgettext", BT_FN_STRING_CONST_STRING_CONST_STRING_INT, ATTR_FORMAT_ARG_2) DEF_EXT_LIB_BUILTIN (BUILT_IN_DGETTEXT, "dgettext", BT_FN_STRING_CONST_STRING_CONST_STRING, ATTR_FORMAT_ARG_2) DEF_GCC_BUILTIN (BUILT_IN_DWARF_CFA, "dwarf_cfa", BT_FN_PTR, ATTR_NULL) -DEF_GCC_BUILTIN (BUILT_IN_DWARF_SP_COLUMN, "dwarf_sp_column", BT_FN_UNSIGNED, ATTR_NULL) +DEF_GCC_BUILTIN (BUILT_IN_DWARF_SP_COLUMN, "dwarf_sp_column", BT_FN_UINT, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_EH_RETURN, "eh_return", BT_FN_VOID_PTRMODE_PTR, ATTR_NORETURN_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_EH_RETURN_DATA_REGNO, "eh_return_data_regno", BT_FN_INT_INT, ATTR_NULL) DEF_EXT_LIB_BUILTIN (BUILT_IN_EXECL, "execl", BT_FN_INT_CONST_STRING_CONST_STRING_VAR, ATTR_NOTHROW_LIST) @@ -565,8 +564,12 @@ DEF_GCC_BUILTIN (BUILT_IN_EXPECT, "expect", BT_FN_LONG_LONG_LONG, ATTR_CONST_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_EXTEND_POINTER, "extend_pointer", BT_FN_WORD_PTR, ATTR_CONST_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_EXTRACT_RETURN_ADDR, "extract_return_addr", BT_FN_PTR_PTR, ATTR_NULL) +DEF_EXT_LIB_BUILTIN (BUILT_IN_FFS, "ffs", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST) +DEF_EXT_LIB_BUILTIN (BUILT_IN_FFSIMAX, "ffsimax", BT_FN_INT_INTMAX, ATTR_CONST_NOTHROW_LIST) +DEF_EXT_LIB_BUILTIN (BUILT_IN_FFSL, "ffsl", BT_FN_INT_LONG, ATTR_CONST_NOTHROW_LIST) +DEF_EXT_LIB_BUILTIN (BUILT_IN_FFSLL, "ffsll", BT_FN_INT_LONGLONG, ATTR_CONST_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN_FORK, "fork", BT_FN_PID, ATTR_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_FRAME_ADDRESS, "frame_address", BT_FN_PTR_UNSIGNED, ATTR_NULL) +DEF_GCC_BUILTIN (BUILT_IN_FRAME_ADDRESS, "frame_address", BT_FN_PTR_UINT, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_FROB_RETURN_ADDR, "frob_return_addr", BT_FN_PTR_PTR, ATTR_NULL) DEF_EXT_LIB_BUILTIN (BUILT_IN_GETTEXT, "gettext", BT_FN_STRING_CONST_STRING, ATTR_FORMAT_ARG_1) DEF_C99_BUILTIN (BUILT_IN_IMAXABS, "imaxabs", BT_FN_INTMAX_INTMAX, ATTR_CONST_NOTHROW_LIST) @@ -591,15 +594,17 @@ DEF_GCC_BUILTIN (BUILT_IN_LONGJMP, "longjmp", BT_FN_VOID_PTR_INT, ATTR_NORETURN_NOTHROW_LIST) DEF_LIB_BUILTIN (BUILT_IN_MALLOC, "malloc", BT_FN_PTR_SIZE, ATTR_MALLOC_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_NEXT_ARG, "next_arg", BT_FN_PTR_VAR, ATTR_NULL) -DEF_GCC_BUILTIN (BUILT_IN_PARITY, "parity", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_PARITYL, "parityl", BT_FN_INT_LONG, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_PARITYLL, "parityll", BT_FN_INT_LONGLONG, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_POPCOUNT, "popcount", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_POPCOUNTL, "popcountl", BT_FN_INT_LONG, ATTR_CONST_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_POPCOUNTLL, "popcountll", BT_FN_INT_LONGLONG, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_PARITY, "parity", BT_FN_INT_UINT, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_PARITYIMAX, "parityimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_PARITYL, "parityl", BT_FN_INT_ULONG, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_PARITYLL, "parityll", BT_FN_INT_ULONGLONG, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_POPCOUNT, "popcount", BT_FN_INT_UINT, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_POPCOUNTIMAX, "popcountimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_POPCOUNTL, "popcountl", BT_FN_INT_ULONG, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_POPCOUNTLL, "popcountll", BT_FN_INT_ULONGLONG, ATTR_CONST_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_PREFETCH, "prefetch", BT_FN_VOID_CONST_PTR_VAR, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_RETURN, "return", BT_FN_VOID_PTR, ATTR_NORETURN_NOTHROW_LIST) -DEF_GCC_BUILTIN (BUILT_IN_RETURN_ADDRESS, "return_address", BT_FN_PTR_UNSIGNED, ATTR_NULL) +DEF_GCC_BUILTIN (BUILT_IN_RETURN_ADDRESS, "return_address", BT_FN_PTR_UINT, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_SAVEREGS, "saveregs", BT_FN_PTR_VAR, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_STACK_ALLOC, "stack_alloc", BT_FN_VOID_PTR_SIZE, ATTR_NULL) --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/builtin-types.def 2004-07-02 15:13:10.000000000 +0200 +++ 2004-07-05.10.09/gcc/builtin-types.def 2004-07-06 17:05:04.184514200 +0200 @@ -61,12 +61,15 @@ DEF_PRIMITIVE_TYPE (BT_VOID, void_type_node) DEF_PRIMITIVE_TYPE (BT_INT, integer_type_node) -DEF_PRIMITIVE_TYPE (BT_UNSIGNED, unsigned_type_node) +DEF_PRIMITIVE_TYPE (BT_UINT, unsigned_type_node) DEF_PRIMITIVE_TYPE (BT_LONG, long_integer_type_node) +DEF_PRIMITIVE_TYPE (BT_ULONG, long_unsigned_type_node) DEF_PRIMITIVE_TYPE (BT_LONGLONG, long_long_integer_type_node) +DEF_PRIMITIVE_TYPE (BT_ULONGLONG, long_long_unsigned_type_node) +DEF_PRIMITIVE_TYPE (BT_INTMAX, intmax_type_node) +DEF_PRIMITIVE_TYPE (BT_UINTMAX, uintmax_type_node) DEF_PRIMITIVE_TYPE (BT_WORD, (*lang_hooks.types.type_for_mode) (word_mode, 0)) DEF_PRIMITIVE_TYPE (BT_FLOAT, float_type_node) -DEF_PRIMITIVE_TYPE (BT_INTMAX, intmax_type_node) DEF_PRIMITIVE_TYPE (BT_DOUBLE, double_type_node) DEF_PRIMITIVE_TYPE (BT_LONGDOUBLE, long_double_type_node) DEF_PRIMITIVE_TYPE (BT_COMPLEX_FLOAT, complex_float_type_node) @@ -96,7 +99,7 @@ DEF_FUNCTION_TYPE_0 (BT_FN_VOID, BT_VOID) DEF_FUNCTION_TYPE_0 (BT_FN_PTR, BT_PTR) DEF_FUNCTION_TYPE_0 (BT_FN_PID, BT_PID) -DEF_FUNCTION_TYPE_0 (BT_FN_UNSIGNED, BT_UNSIGNED) +DEF_FUNCTION_TYPE_0 (BT_FN_UINT, BT_UINT) DEF_FUNCTION_TYPE_0 (BT_FN_FLOAT, BT_FLOAT) DEF_FUNCTION_TYPE_0 (BT_FN_DOUBLE, BT_DOUBLE) /* For "long double" we use LONGDOUBLE (not LONG_DOUBLE) to @@ -123,11 +126,16 @@ BT_DOUBLE, BT_COMPLEX_DOUBLE) DEF_FUNCTION_TYPE_1 (BT_FN_LONGDOUBLE_COMPLEX_LONGDOUBLE, BT_LONGDOUBLE, BT_COMPLEX_LONGDOUBLE) -DEF_FUNCTION_TYPE_1 (BT_FN_PTR_UNSIGNED, BT_PTR, BT_UNSIGNED) +DEF_FUNCTION_TYPE_1 (BT_FN_PTR_UINT, BT_PTR, BT_UINT) DEF_FUNCTION_TYPE_1 (BT_FN_PTR_SIZE, BT_PTR, BT_SIZE) DEF_FUNCTION_TYPE_1 (BT_FN_INT_INT, BT_INT, BT_INT) +DEF_FUNCTION_TYPE_1 (BT_FN_INT_UINT, BT_INT, BT_UINT) DEF_FUNCTION_TYPE_1 (BT_FN_INT_LONG, BT_INT, BT_LONG) +DEF_FUNCTION_TYPE_1 (BT_FN_INT_ULONG, BT_INT, BT_ULONG) DEF_FUNCTION_TYPE_1 (BT_FN_INT_LONGLONG, BT_INT, BT_LONGLONG) +DEF_FUNCTION_TYPE_1 (BT_FN_INT_ULONGLONG, BT_INT, BT_ULONGLONG) +DEF_FUNCTION_TYPE_1 (BT_FN_INT_INTMAX, BT_INT, BT_INTMAX) +DEF_FUNCTION_TYPE_1 (BT_FN_INT_UINTMAX, BT_INT, BT_UINTMAX) DEF_FUNCTION_TYPE_1 (BT_FN_INT_PTR, BT_INT, BT_PTR) DEF_FUNCTION_TYPE_1 (BT_FN_INT_FLOAT, BT_INT, BT_FLOAT) DEF_FUNCTION_TYPE_1 (BT_FN_INT_DOUBLE, BT_INT, BT_DOUBLE) --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.c-torture/execute/builtin-bitops-2.c 1970-01-01 01:00:00.000000000 +0100 +++ 2004-07-05.10.09/gcc/testsuite/gcc.c-torture/execute/builtin-bitops-2.c 2004-06-09 10:13:24.000000000 +0200 @@ -0,0 +1,259 @@ +#include <limits.h> +#if _INTEGRAL_MAX_BITS == 128 +typedef __uint128_t uintmax_t; +# define BITSIZEOF_INTMAX _INTEGRAL_MAX_BITS +#elif UINT_MAX == __ULONG_LONG_MAX__ +typedef unsigned int uintmax_t; +# define BITSIZEOF_INTMAX BITSIZEOF_INT +#elif ULONG_MAX == __ULONG_LONG_MAX__ +typedef unsigned long uintmax_t; +# define BITSIZEOF_INTMAX BITSIZEOF_LONG +#else +typedef unsigned long long uintmax_t; +# define BITSIZEOF_INTMAX BITSIZEOF_LONG_LONG +#endif + +#if __INT_MAX__ > 2147483647L +# if __INT_MAX__ >= 9223372036854775807L +# define BITSIZEOF_INT 64 +# else +# define BITSIZEOF_INT 32 +# endif +#else +# if __INT_MAX__ >= 2147483647L +# define BITSIZEOF_INT 32 +# else +# define BITSIZEOF_INT 16 +# endif +#endif + +#if __LONG_MAX__ > 2147483647L +# if __LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG 64 +# else +# define BITSIZEOF_LONG 32 +# endif +#else +# define BITSIZEOF_LONG 32 +#endif + +#if __LONG_LONG_MAX__ > 2147483647L +# if __LONG_LONG_MAX__ >= 9223372036854775807L +# define BITSIZEOF_LONG_LONG 64 +# else +# define BITSIZEOF_LONG_LONG 32 +# endif +#else +# define BITSIZEOF_LONG_LONG 32 +#endif + +#define MAKE_FUNS(suffix, type) \ +int my_ffs##suffix(type x) { \ + int i; \ + if (x == 0) \ + return 0; \ + for (i = 0; (unsigned)i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + break; \ + return i + 1; \ +} \ + \ +int my_ctz##suffix(type x) { \ + int i; \ + for (i = 0; (unsigned)i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + break; \ + return i; \ +} \ + \ +int my_clz##suffix(type x) { \ + int i; \ + for (i = 0; (unsigned)i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << ((CHAR_BIT * sizeof (type)) - i - 1))) \ + break; \ + return i; \ +} \ + \ +int my_popcount##suffix(type x) { \ + unsigned i; \ + int count = 0; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + count++; \ + return count; \ +} \ + \ +int my_parity##suffix(type x) { \ + unsigned i; \ + int count = 0; \ + for (i = 0; i < CHAR_BIT * sizeof (type); i++) \ + if (x & ((type) 1 << i)) \ + count++; \ + return count & 1; \ +} + +MAKE_FUNS (, unsigned); +MAKE_FUNS (l, unsigned long); +MAKE_FUNS (ll, unsigned long long); +MAKE_FUNS (imax, uintmax_t); + +extern void abort (void); +extern void exit (int); + +#define GLUE2(x, y) x##y +#define GLUE2EXP(x, y) GLUE2(x, y) +#define COMMA , +#define OPEN_PAREN ( +#define CLOSE_PAREN ) + +#define NUMS16(head, suffix, tail) \ + head 0x0000##suffix tail \ + head 0x0001##suffix tail \ + head 0x8000##suffix tail \ + head 0x0002##suffix tail \ + head 0x4000##suffix tail \ + head 0x0100##suffix tail \ + head 0x0080##suffix tail \ + head 0xa5a5##suffix tail \ + head 0x5a5a##suffix tail \ + head 0xcafe##suffix tail \ + head 0xffff##suffix tail + +#define NUMS32(head, suffix, tail) \ + head 0x00000000##suffix tail \ + head 0x00000001##suffix tail \ + head 0x80000000##suffix tail \ + head 0x00000002##suffix tail \ + head 0x40000000##suffix tail \ + head 0x00010000##suffix tail \ + head 0x00008000##suffix tail \ + head 0xa5a5a5a5##suffix tail \ + head 0x5a5a5a5a##suffix tail \ + head 0xcafe0000##suffix tail \ + head 0x00cafe00##suffix tail \ + head 0x0000cafe##suffix tail \ + head 0xffffffff##suffix tail + +#define NUMS64(head, suffix, tail) \ + head 0x0000000000000000##suffix tail \ + head 0x0000000000000001##suffix tail \ + head 0x8000000000000000##suffix tail \ + head 0x0000000000000002##suffix tail \ + head 0x4000000000000000##suffix tail \ + head 0x0000000100000000##suffix tail \ + head 0x0000000080000000##suffix tail \ + head 0xa5a5a5a5a5a5a5a5##suffix tail \ + head 0x5a5a5a5a5a5a5a5a##suffix tail \ + head 0xcafecafe00000000##suffix tail \ + head 0x0000cafecafe0000##suffix tail \ + head 0x00000000cafecafe##suffix tail \ + head 0xffffffffffffffff##suffix tail + +#define NUMS128(head, suffix, tail) \ + head 0x00000000000000000000000000000000##suffix tail \ + head 0x00000000000000000000000000000001##suffix tail \ + head 0x80000000000000000000000000000000##suffix tail \ + head 0x00000000000000000000000000000002##suffix tail \ + head 0x40000000000000000000000000000000##suffix tail \ + head 0x00000000000000010000000000000000##suffix tail \ + head 0x00000000000000008000000000000000##suffix tail \ + head 0xa5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5##suffix tail \ + head 0x5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a##suffix tail \ + head 0xcafecafecafecafe0000000000000000##suffix tail \ + head 0x0000cafecafecafecafe000000000000##suffix tail \ + head 0x00000000cafecafecafecafe00000000##suffix tail \ + head 0x000000000000cafecafecafecafe0000##suffix tail \ + head 0x0000000000000000cafecafecafecafe##suffix tail \ + head 0xffffffffffffffffffffffffffffffff##suffix tail + +unsigned int ints[] = +{ + GLUE2EXP(NUMS, BITSIZEOF_INT)(, U, COMMA) +}; + +unsigned long longs[] = +{ + GLUE2EXP(NUMS, BITSIZEOF_LONG)(, UL, COMMA) +}; + +unsigned long long longlongs[] = +{ + GLUE2EXP(NUMS, BITSIZEOF_LONG_LONG)(, ULL, COMMA) +}; + +uintmax_t maxints[] = +{ + GLUE2EXP(NUMS, BITSIZEOF_INTMAX)(, ULL/* for the lack of a better suffix */, COMMA) +}; + +int +main (void) +{ + unsigned i; + +#define TEST(array, suffix) \ + for (i = 0; i < sizeof (array) / sizeof (array[0]); i++) \ + { \ + if (__builtin_ffs##suffix (array[i]) != my_ffs##suffix (array[i])) \ + abort (); \ + if (array[i] != 0 \ + && __builtin_clz##suffix (array[i]) != my_clz##suffix (array[i])) \ + abort (); \ + if (array[i] != 0 \ + && __builtin_ctz##suffix (array[i]) != my_ctz##suffix (array[i])) \ + abort (); \ + if (__builtin_popcount##suffix (array[i]) != my_popcount##suffix (array[i])) \ + abort (); \ + if (__builtin_parity##suffix (array[i]) != my_parity##suffix (array[i])) \ + abort (); \ + } + + TEST(ints, ); + TEST(longs, l); + TEST(longlongs, ll); + TEST(maxints, imax); + +#undef TEST + + /* Test constant folding. */ + +#define TEST(x, suffix) \ + if (__builtin_ffs##suffix (x) != my_ffs##suffix (x)) \ + abort (); \ + if (x != 0 && __builtin_clz##suffix (x) != my_clz##suffix (x)) \ + abort (); \ + if (x != 0 && __builtin_ctz##suffix (x) != my_ctz##suffix (x)) \ + abort (); \ + if (__builtin_popcount##suffix (x) != my_popcount##suffix (x)) \ + abort (); \ + if (__builtin_parity##suffix (x) != my_parity##suffix (x)) \ + abort (); + +#if BITSIZEOF_INT == 16 + NUMS16(TEST OPEN_PAREN, U, COMMA CLOSE_PAREN) +#endif + +#if BITSIZEOF_INT == 32 + NUMS32(TEST OPEN_PAREN, U, COMMA CLOSE_PAREN) +#elif BITSIZEOF_LONG == 32 + NUMS32(TEST OPEN_PAREN, UL, COMMA l CLOSE_PAREN) +#endif + +#if BITSIZEOF_LONG == 64 + NUMS64(TEST OPEN_PAREN, UL, COMMA l CLOSE_PAREN) +#elif BITSIZEOF_LONG_LONG == 64 + NUMS64(TEST OPEN_PAREN, ULL, COMMA ll CLOSE_PAREN) +#elif BITSIZEOF_INTMAX == 64 + NUMS64(TEST OPEN_PAREN, ULL, COMMA imax CLOSE_PAREN) +#endif + +#if BITSIZEOF_LONG_LONG == 128 + NUMS128(TEST OPEN_PAREN, ULL, COMMA ll CLOSE_PAREN) +#elif BITSIZEOF_INTMAX == 128 + NUMS128(TEST OPEN_PAREN, ULL/* for the lack of a better suffix */, COMMA imax CLOSE_PAREN) +#endif + +#undef TEST + + exit (0); +} --- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/testsuite/gcc.dg/builtin-protos-1.c 1970-01-01 01:00:00.000000000 +0100 +++ 2004-07-05.10.09/gcc/testsuite/gcc.dg/builtin-protos-1.c 2004-06-02 10:58:41.000000000 +0200 @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options -Wconversion } */ + +int test_s(signed int x) { + return __builtin_abs(x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_clz(x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_ctz(x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_ffs(x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_parity(x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_popcount(x); /* { dg-warning "as unsigned due to prototype" } */ +} + +int test_u(unsigned int x) { + return __builtin_abs(x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_clz(x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_ctz(x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_ffs(x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_parity(x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_popcount(x); /* { dg-bogus "as signed due to prototype" } */ +} + +int test_sl(signed long x) { + return __builtin_labs(x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_clzl(x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_ctzl(x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_ffsl(x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_parityl(x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_popcountl(x); /* { dg-warning "as unsigned due to prototype" } */ +} + +int test_ul(unsigned long x) { + return __builtin_labs(x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_clzl(x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_ctzl(x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_ffsl(x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_parityl(x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_popcountl(x); /* { dg-bogus "as signed due to prototype" } */ +} + +int test_sll(signed long long x) { + return __builtin_llabs(x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_clzll(x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_ctzll(x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_ffsll(x) /* { dg-bogus "as unsigned due to prototype" } */ + + __builtin_parityll(x) /* { dg-warning "as unsigned due to prototype" } */ + + __builtin_popcountll(x); /* { dg-warning "as unsigned due to prototype" } */ +} + +int test_ull(unsigned long long x) { + return __builtin_llabs(x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_clzll(x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_ctzll(x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_ffsll(x) /* { dg-warning "as signed due to prototype" } */ + + __builtin_parityll(x) /* { dg-bogus "as signed due to prototype" } */ + + __builtin_popcountll(x); /* { dg-bogus "as signed due to prototype" } */ +}
--- Begin Message ---
- From: "Jim Wilson" <wilson dot INET-PRV1 at specifixinc dot com>
- Date: Thu, 20 May 2004 01:02:26 +0200
- Subject: Re: types of new builtins
Jan Beulich wrote: > Why do the (new) bit-op builtins have prototypes with signed parameters > instead of unsigned ones? Because no one else noticed the mistake before. > Interestingly, all these bit operation functions are documented to take > unsigned arguments (on Other-Builtins.html). Also, the libgcc2.c versions of these functions have unsigned arguments. Clearly, they were intended to be functions that take unsigned arguments. The builtins.def file should be fixed. Submit a patch, or file a bug report into bugzilla. -- Jim Wilson, GNU Tools Support, http://www.SpecifixInc.comAttachment: Mime.822
Description: Binary data
--- End Message ---
Attachment:
gcc-mainline-builtin-protos.patch
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |