diff options
Diffstat (limited to 'gcc/c-typeck.c')
| -rw-r--r-- | gcc/c-typeck.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 6b198f9310d..47fa1855ad3 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -173,6 +173,28 @@ c_incomplete_type_error (value, type) } } +/* Given a type, apply default promotions wrt unnamed function + arguments and return the new type. */ + +tree +c_type_promotes_to (type) + tree type; +{ + if (TYPE_MAIN_VARIANT (type) == float_type_node) + return double_type_node; + + if (c_promoting_integer_type_p (type)) + { + /* Preserve unsignedness if not really getting any wider. */ + if (TREE_UNSIGNED (type) + && (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))) + return unsigned_type_node; + return integer_type_node; + } + + return type; +} + /* Return a variant of TYPE which has all the type qualifiers of LIKE as well as those of TYPE. */ @@ -658,12 +680,12 @@ type_lists_compatible_p (args1, args2) So match anything that self-promotes. */ if (TREE_VALUE (args1) == 0) { - if (simple_type_promotes_to (TREE_VALUE (args2)) != NULL_TREE) + if (c_type_promotes_to (TREE_VALUE (args2)) != TREE_VALUE (args2)) return 0; } else if (TREE_VALUE (args2) == 0) { - if (simple_type_promotes_to (TREE_VALUE (args1)) != NULL_TREE) + if (c_type_promotes_to (TREE_VALUE (args1)) != TREE_VALUE (args1)) return 0; } else if (! (newval = comptypes (TYPE_MAIN_VARIANT (TREE_VALUE (args1)), |

