From 4c7a6c1bdb63272d47cbe9aa39b2ee64d3a63fa4 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sat, 3 Dec 2005 18:58:43 +0000 Subject: c-common.c (c_sizeof_or_alignof_type): Use fold_convert instead of building a NOP_EXPR. * c-common.c (c_sizeof_or_alignof_type): Use fold_convert instead of building a NOP_EXPR. (c_alignof_expr): Likewise. Handle CONVERT_EXPR the same as NOP_EXPR. * c-convert.c (convert): Use fold_convert instead of building NOP_EXPRs and CONVERT_EXPRs directly. Don't special case c_objc_common_truthvalue_conversion returning a NOP_EXPR. Remove #if 0 code. * c-pretty-print.c (pp_c_cast_expression, pp_c_expression): Handle NOP_EXPR the same as CONVERT_EXPR. * c-typeck.c (build_function_call): Use fold_convert instead of building a NOP_EXPR directly. (build_compound_expr): Handle NOP_EXPR the same as CONVERT_EXPR. testsuite: * gcc.dg/cast-pretty-print-1.c: New test. From-SVN: r108001 --- gcc/c-convert.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'gcc/c-convert.c') diff --git a/gcc/c-convert.c b/gcc/c-convert.c index 50bb923..bf306c8 100644 --- a/gcc/c-convert.c +++ b/gcc/c-convert.c @@ -88,7 +88,7 @@ convert (tree type, tree expr) return expr; if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr))) - return fold_build1 (NOP_EXPR, type, expr); + return fold_convert (type, expr); if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK) return error_mark_node; if (TREE_CODE (TREE_TYPE (expr)) == VOID_TYPE) @@ -97,28 +97,11 @@ convert (tree type, tree expr) return error_mark_node; } if (code == VOID_TYPE) - return build1 (CONVERT_EXPR, type, e); -#if 0 - /* This is incorrect. A truncation can't be stripped this way. - Extensions will be stripped by the use of get_unwidened. */ - if (TREE_CODE (expr) == NOP_EXPR) - return convert (type, TREE_OPERAND (expr, 0)); -#endif + return fold_convert (type, e); if (code == INTEGER_TYPE || code == ENUMERAL_TYPE) return fold (convert_to_integer (type, e)); if (code == BOOLEAN_TYPE) - { - tree t = c_objc_common_truthvalue_conversion (expr); - if (TREE_CODE (t) == ERROR_MARK) - return t; - - /* If it returns a NOP_EXPR, we must fold it here to avoid - infinite recursion between fold () and convert (). */ - if (TREE_CODE (t) == NOP_EXPR) - return fold_build1 (NOP_EXPR, type, TREE_OPERAND (t, 0)); - else - return fold_build1 (NOP_EXPR, type, t); - } + return fold_convert (type, c_objc_common_truthvalue_conversion (expr)); if (code == POINTER_TYPE || code == REFERENCE_TYPE) return fold (convert_to_pointer (type, e)); if (code == REAL_TYPE) -- cgit v1.1