diff options
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 25 |
2 files changed, 27 insertions, 4 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index c1e204d..fc077a8 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2018-03-21 Joseph Myers <joseph@codesourcery.com> + + * 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. + 2018-03-21 Jakub Jelinek <jakub@redhat.com> PR c/84999 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 945838c..4772086 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -8530,10 +8530,12 @@ c_parser_postfix_expression (c_parser *parser) argument is decimal, or if the only alternatives for type-generic arguments are of decimal types, and are otherwise treated as double (or _Complex double for - complex integer types). After that adjustment, types - are combined following the usual arithmetic - conversions. If the function only accepts complex - arguments, a complex type is produced. */ + complex integer types, or _Float64 or _Complex _Float64 + if all the return types are the same _FloatN or + _FloatNx type). After that adjustment, types are + combined following the usual arithmetic conversions. + If the function only accepts complex arguments, a + complex type is produced. */ bool arg_complex = all_complex; bool arg_binary = all_binary; bool arg_int_decimal = all_decimal; @@ -8632,6 +8634,19 @@ c_parser_postfix_expression (c_parser *parser) } } } + /* For a macro rounding its result to a narrower type, map + integer types to _Float64 not double if the return type + is a _FloatN or _FloatNx type. */ + bool arg_int_float64 = false; + if (parm_kind[0] == tgmath_fixed + && SCALAR_FLOAT_TYPE_P (parm_first[0]) + && float64_type_node != NULL_TREE) + for (unsigned int j = 0; j < NUM_FLOATN_NX_TYPES; j++) + if (parm_first[0] == FLOATN_TYPE_NODE (j)) + { + arg_int_float64 = true; + break; + } tree arg_real = NULL_TREE; for (unsigned int j = 1; j <= nargs; j++) { @@ -8644,6 +8659,8 @@ c_parser_postfix_expression (c_parser *parser) if (INTEGRAL_TYPE_P (type)) type = (arg_int_decimal ? dfloat64_type_node + : arg_int_float64 + ? float64_type_node : double_type_node); if (arg_real == NULL_TREE) arg_real = type; |