+2005-12-03 Joseph S. Myers <joseph@codesourcery.com>
+
+ * 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.
+
2005-12-03 Alan Modra <amodra@bigpond.net.au>
PR rtl-optimization/25197
TYPE_IS_SIZETYPE means that certain things (like overflow) will
never happen. However, this node should really have type
`size_t', which is just a typedef for an ordinary integer type. */
- value = fold_build1 (NOP_EXPR, size_type_node, value);
+ value = fold_convert (size_type_node, value);
gcc_assert (!TYPE_IS_SIZETYPE (TREE_TYPE (value)));
return value;
tree best = t;
int bestalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
- while (TREE_CODE (t) == NOP_EXPR
+ while ((TREE_CODE (t) == NOP_EXPR || TREE_CODE (t) == CONVERT_EXPR)
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == POINTER_TYPE)
{
int thisalign;
else
return c_alignof (TREE_TYPE (expr));
- return fold_build1 (NOP_EXPR, size_type_node, t);
+ return fold_convert (size_type_node, t);
}
\f
/* Handle C and C++ default attributes. */
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)
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)
case FLOAT_EXPR:
case FIX_TRUNC_EXPR:
case CONVERT_EXPR:
+ case NOP_EXPR:
pp_c_type_cast (pp, TREE_TYPE (e));
pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
break;
case FLOAT_EXPR:
case FIX_TRUNC_EXPR:
case CONVERT_EXPR:
+ case NOP_EXPR:
pp_c_cast_expression (pp, e);
break;
pp_c_right_paren (pp);
break;
- case NOP_EXPR:
case NON_LVALUE_EXPR:
case SAVE_EXPR:
pp_expression (pp, TREE_OPERAND (e, 0));
rhs = build_compound_literal (return_type,
build_constructor (return_type, 0));
else
- rhs = fold_build1 (NOP_EXPR, return_type, integer_zero_node);
+ rhs = fold_convert (return_type, integer_zero_node);
return build2 (COMPOUND_EXPR, return_type, trap, rhs);
}
if (warn_unused_value)
{
if (VOID_TYPE_P (TREE_TYPE (expr1))
- && TREE_CODE (expr1) == CONVERT_EXPR)
+ && (TREE_CODE (expr1) == NOP_EXPR
+ || TREE_CODE (expr1) == CONVERT_EXPR))
; /* (void) a, b */
else if (VOID_TYPE_P (TREE_TYPE (expr1))
&& TREE_CODE (expr1) == COMPOUND_EXPR
- && TREE_CODE (TREE_OPERAND (expr1, 1)) == CONVERT_EXPR)
+ && (TREE_CODE (TREE_OPERAND (expr1, 1)) == CONVERT_EXPR
+ || TREE_CODE (TREE_OPERAND (expr1, 1)) == NOP_EXPR))
; /* (void) a, (void) b, c */
else
warning (0, "left-hand operand of comma expression has no effect");
+2005-12-03 Joseph S. Myers <joseph@codesourcery.com>
+
+ * gcc.dg/cast-pretty-print-1.c: New test.
+
2005-12-03 Joseph S. Myers <joseph@codesourcery.com>
* gcc.dg/c90-const-expr-4.c, gcc.dg/c99-const-expr-4.c: New tests.
--- /dev/null
+/* Test pretty-printing of casts. Should not depend on whether
+ NOP_EXPR or CONVERT_EXPR is used. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+int i;
+void
+f (void)
+{
+ ((unsigned int)i)(); /* { dg-error "error: called object '\\(unsigned int\\)i' is not a function" } */
+ ((char)i)(); /* { dg-error "error: called object '\\(char\\)i' is not a function" } */
+}