aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2005-03-23 01:29:08 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2005-03-23 01:29:08 +0000
commit522ddfa2543f57daddbb9cd8e2a44d8f6425396e (patch)
treea494e1e283e1b20afad26e4574a3526f1d4d5e5b /gcc/c-typeck.c
parent54b73ddf159ae2adb5bf5c6e9b8a57fda0da0256 (diff)
downloadgcc-522ddfa2543f57daddbb9cd8e2a44d8f6425396e.zip
gcc-522ddfa2543f57daddbb9cd8e2a44d8f6425396e.tar.gz
gcc-522ddfa2543f57daddbb9cd8e2a44d8f6425396e.tar.bz2
c-common.h (default_conversion): Remove.
* c-common.h (default_conversion): Remove. (perform_integral_promotions): Add. * c-tree.h (default_conversion): Add. * c-typeck.c (perform_integral_promotions): New, split out from default_conversion. * c-common.c (check_case_value): Use perform_integral_promotions, not default_conversion. (c_add_case_label): Don't continue processing case label after found to be pointer. cp: * cp-tree.h (perform_integral_promotions): Remove. (default_conversion): Add. From-SVN: r96916
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c77
1 files changed, 49 insertions, 28 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index d5046d5..a89c87a 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -1352,40 +1352,17 @@ default_function_array_conversion (tree exp)
return exp;
}
-/* Perform default promotions for C data used in expressions.
- Arrays and functions are converted to pointers;
- enumeral types or short or char, to int.
- In addition, manifest constants symbols are replaced by their values. */
+
+/* EXP is an expression of integer type. Apply the integer promotions
+ to it and return the promoted value. */
tree
-default_conversion (tree exp)
+perform_integral_promotions (tree exp)
{
- tree orig_exp;
tree type = TREE_TYPE (exp);
enum tree_code code = TREE_CODE (type);
- if (code == FUNCTION_TYPE || code == ARRAY_TYPE)
- return default_function_array_conversion (exp);
-
- /* Constants can be used directly unless they're not loadable. */
- if (TREE_CODE (exp) == CONST_DECL)
- exp = DECL_INITIAL (exp);
-
- /* Replace a nonvolatile const static variable with its value unless
- it is an array, in which case we must be sure that taking the
- address of the array produces consistent results. */
- else if (optimize && TREE_CODE (exp) == VAR_DECL && code != ARRAY_TYPE)
- {
- exp = decl_constant_value_for_broken_optimization (exp);
- type = TREE_TYPE (exp);
- }
-
- /* Strip no-op conversions. */
- orig_exp = exp;
- STRIP_TYPE_NOPS (exp);
-
- if (TREE_NO_WARNING (orig_exp))
- TREE_NO_WARNING (exp) = 1;
+ gcc_assert (INTEGRAL_TYPE_P (type));
/* Normally convert enums to int,
but convert wide enums to something wider. */
@@ -1400,6 +1377,8 @@ default_conversion (tree exp)
return convert (type, exp);
}
+ /* ??? This should no longer be needed now bit-fields have their
+ proper types. */
if (TREE_CODE (exp) == COMPONENT_REF
&& DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1))
/* If it's thinner than an int, promote it like a
@@ -1418,6 +1397,48 @@ default_conversion (tree exp)
return convert (integer_type_node, exp);
}
+ return exp;
+}
+
+
+/* Perform default promotions for C data used in expressions.
+ Arrays and functions are converted to pointers;
+ enumeral types or short or char, to int.
+ In addition, manifest constants symbols are replaced by their values. */
+
+tree
+default_conversion (tree exp)
+{
+ tree orig_exp;
+ tree type = TREE_TYPE (exp);
+ enum tree_code code = TREE_CODE (type);
+
+ if (code == FUNCTION_TYPE || code == ARRAY_TYPE)
+ return default_function_array_conversion (exp);
+
+ /* Constants can be used directly unless they're not loadable. */
+ if (TREE_CODE (exp) == CONST_DECL)
+ exp = DECL_INITIAL (exp);
+
+ /* Replace a nonvolatile const static variable with its value unless
+ it is an array, in which case we must be sure that taking the
+ address of the array produces consistent results. */
+ else if (optimize && TREE_CODE (exp) == VAR_DECL && code != ARRAY_TYPE)
+ {
+ exp = decl_constant_value_for_broken_optimization (exp);
+ type = TREE_TYPE (exp);
+ }
+
+ /* Strip no-op conversions. */
+ orig_exp = exp;
+ STRIP_TYPE_NOPS (exp);
+
+ if (TREE_NO_WARNING (orig_exp))
+ TREE_NO_WARNING (exp) = 1;
+
+ if (INTEGRAL_TYPE_P (type))
+ return perform_integral_promotions (exp);
+
if (code == VOID_TYPE)
{
error ("void value not ignored as it ought to be");