- 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
- if (code == INTEGER_TYPE || code == ENUMERAL_TYPE)
- return fold (convert_to_integer (type, e));
- if (code == POINTER_TYPE)
- return fold (convert_to_pointer (type, e));
- if (code == REAL_TYPE)
- return fold (convert_to_real (type, e));
- if (code == COMPLEX_TYPE)
- return fold (convert_to_complex (type, e));
+
+ switch (code)
+ {
+ case VOID_TYPE:
+ return fold_convert_loc (loc, type, e);
+
+ case INTEGER_TYPE:
+ case ENUMERAL_TYPE:
+ ret = convert_to_integer (type, e);
+ goto maybe_fold;
+
+ case BOOLEAN_TYPE:
+ return fold_convert_loc
+ (loc, type, c_objc_common_truthvalue_conversion (input_location, expr));
+
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ ret = convert_to_pointer (type, e);
+ goto maybe_fold;
+
+ case REAL_TYPE:
+ ret = convert_to_real (type, e);
+ goto maybe_fold;
+
+ case FIXED_POINT_TYPE:
+ ret = convert_to_fixed (type, e);
+ goto maybe_fold;
+
+ case COMPLEX_TYPE:
+ ret = convert_to_complex (type, e);
+ goto maybe_fold;
+
+ case VECTOR_TYPE:
+ ret = convert_to_vector (type, e);
+ goto maybe_fold;
+
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ if (lang_hooks.types_compatible_p (type, TREE_TYPE (expr)))
+ return e;
+ break;
+
+ default:
+ break;
+
+ maybe_fold:
+ if (TREE_CODE (ret) != C_MAYBE_CONST_EXPR)
+ ret = fold (ret);
+ return ret;
+ }