aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2001-04-30 16:59:10 -0700
committerRichard Henderson <rth@gcc.gnu.org>2001-04-30 16:59:10 -0700
commitd72040f508bfc01489f0fca666cbb6e8ddfae896 (patch)
tree1e7389002ae91d660ddd3c0a718444a33765d0ae /gcc/c-common.c
parent901d43bcd00712e558ce9d408c788980b6823c13 (diff)
downloadgcc-d72040f508bfc01489f0fca666cbb6e8ddfae896.zip
gcc-d72040f508bfc01489f0fca666cbb6e8ddfae896.tar.gz
gcc-d72040f508bfc01489f0fca666cbb6e8ddfae896.tar.bz2
c-common.c (c_promoting_integer_type_p): New function, from the corpse of old macro.
* c-common.c (c_promoting_integer_type_p): New function, from the corpse of old macro. Properly promote too-small enumerations and booleans. Adjust all callers. * c-common.h (C_PROMOTING_INTEGER_TYPE_P): Remove. (c_promoting_integer_type_p): Declare. * c-decl.c: Adjust C_PROMOTING_INTEGER_TYPE_P invocations. * c-typeck.c: Likewise. (default_conversion): Remove now redundant boolean check. * cvt.c: Downcase C_PROMOTING_INTEGER_TYPE_P invocations. * decl.c: Likewise. From-SVN: r41709
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 8727503..a87ad7e 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -3690,6 +3690,36 @@ builtin_function_2 (builtin_name, name, builtin_type, type, function_code,
return (bdecl != 0 ? bdecl : decl);
}
+/* Nonzero if the type T promotes to int. This is (nearly) the
+ integral promotions defined in ISO C99 6.3.1.1/2. */
+
+bool
+c_promoting_integer_type_p (t)
+ tree t;
+{
+ switch (TREE_CODE (t))
+ {
+ case INTEGER_TYPE:
+ return (TYPE_MAIN_VARIANT (t) == char_type_node
+ || TYPE_MAIN_VARIANT (t) == signed_char_type_node
+ || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node
+ || TYPE_MAIN_VARIANT (t) == short_integer_type_node
+ || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node);
+
+ case ENUMERAL_TYPE:
+ /* ??? Technically all enumerations not larger than an int
+ promote to an int. But this is used along code paths
+ that only want to notice a size change. */
+ return TYPE_PRECISION (t) < TYPE_PRECISION (integer_type_node);
+
+ case BOOLEAN_TYPE:
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
/* Given a type, apply default promotions wrt unnamed function arguments
and return the new type. Return NULL_TREE if no change. */
/* ??? There is a function of the same name in the C++ front end that
@@ -3704,7 +3734,7 @@ simple_type_promotes_to (type)
if (TYPE_MAIN_VARIANT (type) == float_type_node)
return double_type_node;
- if (C_PROMOTING_INTEGER_TYPE_P (type))
+ if (c_promoting_integer_type_p (type))
{
/* Traditionally, unsignedness is preserved in default promotions.
Also preserve unsignedness if not really getting any wider. */
@@ -3739,7 +3769,7 @@ self_promoting_args_p (parms)
if (TYPE_MAIN_VARIANT (type) == float_type_node)
return 0;
- if (C_PROMOTING_INTEGER_TYPE_P (type))
+ if (c_promoting_integer_type_p (type))
return 0;
}
return 1;