-
Adjust __builtin_tgmath handling of integer arguments to _FloatN narrowing macros. · c5c5822a
When adding __builtin_tgmath to support a better tgmath.h implementation, I noted that further changes might be needed regarding the TS 18661 functions that round their results to a narrower type, because of unresolved issues with how the corresponding type-generic macros are defined in TS 18661. The resolution of those issues is still in flux, but the latest version does indeed require something slightly different from __builtin_tgmath. It specifies that integer arguments to type-generic macros such as f32xadd are treated as _Float64 not double - which was also present in earlier versions of the resolution - but then it also specifies different handling for _Float64 arguments and double arguments, which wasn't in earlier versions. Specifically, in the latest version <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2213.pdf>, f32xadd with _Float64 arguments would call f32xaddf64, while f32xadd with double arguments would call f32xaddf64x. Since integer arguments are converted directly to the argument type of the selected function (not to double / _Float64x unless that ends up as the argument type), this is a user-visible difference in semantics that means __builtin_tgmath actually needs to implement treating integer arguments as _Float64 in this case (the rest of the latest semantics can then be implemented in the header, with a few inline functions there). To avoid releasing with the older version of the __builtin_tgmath semantics that doesn't work with the latest proposed DR#13 resolution, this patch implements a rule in __builtin_tgmath that maps integer types to _Float64 (respectively _Complex _Float64 for complex integer types) where all the specified functions return the same _FloatN or _FloatNx type. This does not affect any existing uses of __builtin_tgmath in glibc's or GCC's tgmath.h since I haven't yet added any of these type-generic macros to glibc when adding the corresponding narrowing functions. Bootstrapped with no regressions on x86_64-pc-linux-gnu. * doc/extend.texi (__builtin_tgmath): Document when complex integer types are treated as _Complex _Float64. gcc/c: * c-parser.c (c_parser_postfix_expression): For __builtin_tgmath where all functions return the same _FloatN or _FloatNx type, treat integer types as _Float64 instead of double. gcc/testsuite: * gcc.dg/builtin-tgmath-3.c: New test. From-SVN: r258751
Joseph Myers committed
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
ChangeLog | Loading commit data... | |
Make-lang.in | Loading commit data... | |
c-aux-info.c | Loading commit data... | |
c-convert.c | Loading commit data... | |
c-decl.c | Loading commit data... | |
c-errors.c | Loading commit data... | |
c-fold.c | Loading commit data... | |
c-lang.c | Loading commit data... | |
c-lang.h | Loading commit data... | |
c-objc-common.c | Loading commit data... | |
c-objc-common.h | Loading commit data... | |
c-parser.c | Loading commit data... | |
c-parser.h | Loading commit data... | |
c-tree.h | Loading commit data... | |
c-typeck.c | Loading commit data... | |
config-lang.in | Loading commit data... | |
gccspec.c | Loading commit data... | |
gimple-parser.c | Loading commit data... | |
gimple-parser.h | Loading commit data... |