diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-01 08:46:10 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-01 08:46:10 +0000 |
commit | 4070745f3e4ba2049ee164b06b5418e35d4c2a40 (patch) | |
tree | a06146fa6279ee4373ef4b809f8c3aedca99fb3f /gcc/c-common.c | |
parent | 804bf398724e01b2c9f67e915430711b774a38cb (diff) | |
download | gcc-4070745f3e4ba2049ee164b06b5418e35d4c2a40.tar.gz |
* c-common.c (unsigned_conversion_warning, convert_and_check,
unsigned_type, signed_type, shorten_compare,
c_common_get_alias_set, c_common_nodes_and_builtins): Use new hooks.
(unsigned_type, signed_type, signed_or_unsigned_type): Rename.
* c-common.h (unsigned_type, signed_type, signed_or_unsigned_type):
New.
* c-decl.c (grokdeclarator): Update.
* c-format.c (check_format_types): Update.
* c-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* c-typeck.c (build_binary_op, convert_for_assignment): Update.
* convert.c (convert_to_integer): Use new hooks.
* expmed.c (make_tree): Use new hooks.
* expr.c (store_expr): Use new hooks.
* fold-const.c (operand_equal_for_comparison_p, build_range_check,
all_ones_mask_p, unextend, fold): Use new hooks.
* langhooks.h (struct lang_hooks_for_types): New hooks.
* tree.h (signed_or_unsigned_type, signed_type,
unsigned_type): Remove.
ada:
* gigi.h (unsigned_type, signed_type, signed_or_unsigned_type):
Rename.
* misc.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* trans.c (tree_transform, convert_with_check): Update.
* utils.c (unsigned_type, signed_type, signed_or_unsigned_type):
Rename.
cp:
* cp-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* decl.c (grokdeclarator): Update.
* mangle.c (write_integer_cst): Update.
* typeck.c (build_binary_op): Update.
f:
* com.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
(unsigned_type, signed_type, signed_or_unsigned_type): Rename.
java:
* expr.c (build_java_binop): Update.
* java-tree.h (java_signed_type, java_unsigned_type,
java_signed_or_unsigned_type): Update.
* lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* parse.y (patch_binop): Update.
* typeck.c (signed_or_unsigned_type, unsigned_type,
signed_type): Update.
objc:
* objc-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51684 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index a3fa0173726..04cd3c462e8 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -757,13 +757,15 @@ void unsigned_conversion_warning (result, operand) tree result, operand; { + tree type = TREE_TYPE (result); + if (TREE_CODE (operand) == INTEGER_CST - && TREE_CODE (TREE_TYPE (result)) == INTEGER_TYPE - && TREE_UNSIGNED (TREE_TYPE (result)) + && TREE_CODE (type) == INTEGER_TYPE + && TREE_UNSIGNED (type) && skip_evaluation == 0 - && !int_fits_type_p (operand, TREE_TYPE (result))) + && !int_fits_type_p (operand, type)) { - if (!int_fits_type_p (operand, signed_type (TREE_TYPE (result)))) + if (!int_fits_type_p (operand, c_common_signed_type (type))) /* This detects cases like converting -129 or 256 to unsigned char. */ warning ("large integer implicitly truncated to unsigned type"); else if (warn_conversion) @@ -812,7 +814,8 @@ convert_and_check (type, expr) don't warn unless pedantic. */ if ((pedantic || TREE_UNSIGNED (type) - || ! constant_fits_type_p (expr, unsigned_type (type))) + || ! constant_fits_type_p (expr, + c_common_unsigned_type (type))) && skip_evaluation == 0) warning ("overflow in implicit constant conversion"); } @@ -1435,7 +1438,7 @@ c_common_type_for_mode (mode, unsignedp) /* Return an unsigned type the same as TYPE in other respects. */ tree -unsigned_type (type) +c_common_unsigned_type (type) tree type; { tree type1 = TYPE_MAIN_VARIANT (type); @@ -1464,13 +1467,13 @@ unsigned_type (type) if (type1 == intQI_type_node) return unsigned_intQI_type_node; - return signed_or_unsigned_type (1, type); + return c_common_signed_or_unsigned_type (1, type); } /* Return a signed type the same as TYPE in other respects. */ tree -signed_type (type) +c_common_signed_type (type) tree type; { tree type1 = TYPE_MAIN_VARIANT (type); @@ -1499,14 +1502,14 @@ signed_type (type) if (type1 == unsigned_intQI_type_node) return intQI_type_node; - return signed_or_unsigned_type (0, type); + return c_common_signed_or_unsigned_type (0, type); } /* Return a type the same as TYPE except unsigned or signed according to UNSIGNEDP. */ tree -signed_or_unsigned_type (unsignedp, type) +c_common_signed_or_unsigned_type (unsignedp, type) int unsignedp; tree type; { @@ -1755,7 +1758,8 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr) int unsignedp = TREE_UNSIGNED (*restype_ptr); tree val; - type = signed_or_unsigned_type (unsignedp0, TREE_TYPE (primop0)); + type = c_common_signed_or_unsigned_type (unsignedp0, + TREE_TYPE (primop0)); /* If TYPE is an enumeration, then we need to get its min/max values from it's underlying integral type, not the enumerated @@ -1767,7 +1771,7 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr) minval = TYPE_MIN_VALUE (type); if (unsignedp && !unsignedp0) - *restype_ptr = signed_type (*restype_ptr); + *restype_ptr = c_common_signed_type (*restype_ptr); if (TREE_TYPE (primop1) != *restype_ptr) primop1 = convert (*restype_ptr, primop1); @@ -1864,7 +1868,7 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr) default: break; } - type = unsigned_type (type); + type = c_common_unsigned_type (type); } if (!max_gt && !unsignedp0 && TREE_CODE (primop0) != INTEGER_CST) @@ -1916,15 +1920,19 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr) && TYPE_PRECISION (TREE_TYPE (primop1)) < TYPE_PRECISION (*restype_ptr)) { type = common_type (TREE_TYPE (primop0), TREE_TYPE (primop1)); - type = signed_or_unsigned_type (unsignedp0 - || TREE_UNSIGNED (*restype_ptr), - type); + type = c_common_signed_or_unsigned_type (unsignedp0 + || TREE_UNSIGNED (*restype_ptr), + type); /* Make sure shorter operand is extended the right way to match the longer operand. */ - primop0 = convert (signed_or_unsigned_type (unsignedp0, TREE_TYPE (primop0)), - primop0); - primop1 = convert (signed_or_unsigned_type (unsignedp1, TREE_TYPE (primop1)), - primop1); + primop0 + = convert (c_common_signed_or_unsigned_type (unsignedp0, + TREE_TYPE (primop0)), + primop0); + primop1 + = convert (c_common_signed_or_unsigned_type (unsignedp1, + TREE_TYPE (primop1)), + primop1); } else { @@ -1947,7 +1955,7 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr) so suppress the warning. */ if (extra_warnings && !in_system_header && ! (TREE_CODE (primop0) == INTEGER_CST - && ! TREE_OVERFLOW (convert (signed_type (type), + && ! TREE_OVERFLOW (convert (c_common_signed_type (type), primop0)))) warning ("comparison of unsigned expression >= 0 is always true"); value = boolean_true_node; @@ -1956,7 +1964,7 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr) case LT_EXPR: if (extra_warnings && !in_system_header && ! (TREE_CODE (primop0) == INTEGER_CST - && ! TREE_OVERFLOW (convert (signed_type (type), + && ! TREE_OVERFLOW (convert (c_common_signed_type (type), primop0)))) warning ("comparison of unsigned expression < 0 is always false"); value = boolean_false_node; @@ -2365,7 +2373,7 @@ c_common_get_alias_set (t) variant as canonical. */ if (TREE_CODE (t) == INTEGER_TYPE && TREE_UNSIGNED (t)) { - tree t1 = signed_type (t); + tree t1 = c_common_signed_type (t); /* t1 == t can happen for boolean nodes which are always unsigned. */ if (t1 != t) @@ -2621,7 +2629,7 @@ c_common_nodes_and_builtins () and this must agree, even if long and int are the same size. */ c_size_type_node = TREE_TYPE (identifier_global_value (get_identifier (SIZE_TYPE))); - signed_size_type_node = signed_type (c_size_type_node); + signed_size_type_node = c_common_signed_type (c_size_type_node); set_sizetype (c_size_type_node); build_common_tree_nodes_2 (flag_short_double); @@ -2690,8 +2698,8 @@ c_common_nodes_and_builtins () } else { - signed_wchar_type_node = signed_type (wchar_type_node); - unsigned_wchar_type_node = unsigned_type (wchar_type_node); + signed_wchar_type_node = c_common_signed_type (wchar_type_node); + unsigned_wchar_type_node = c_common_unsigned_type (wchar_type_node); } /* This is for wide string constants. */ @@ -2709,7 +2717,7 @@ c_common_nodes_and_builtins () default_function_type = build_function_type (integer_type_node, NULL_TREE); ptrdiff_type_node = TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE))); - unsigned_ptrdiff_type_node = unsigned_type (ptrdiff_type_node); + unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node); (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"), |