===================================================================
@@ -7136,21 +7136,21 @@ fold_plusminus_mult_expr (location_t loc
alt1 = arg10;
same = maybe_same;
if (swap)
maybe_same = alt0, alt0 = alt1, alt1 = maybe_same;
}
}
if (!same)
return NULL_TREE;
- if (! INTEGRAL_TYPE_P (type)
+ if (! ANY_INTEGRAL_TYPE_P (type)
|| TYPE_OVERFLOW_WRAPS (type)
/* We are neither factoring zero nor minus one. */
|| TREE_CODE (same) == INTEGER_CST)
return fold_build2_loc (loc, MULT_EXPR, type,
fold_build2_loc (loc, code, type,
fold_convert_loc (loc, type, alt0),
fold_convert_loc (loc, type, alt1)),
fold_convert_loc (loc, type, same));
/* Same may be zero and thus the operation 'code' may overflow. Likewise
===================================================================
@@ -11202,34 +11202,45 @@ int_cst_value (const_tree x)
return val;
}
/* If TYPE is an integral or pointer type, return an integer type with
the same precision which is unsigned iff UNSIGNEDP is true, or itself
if TYPE is already an integer type of signedness UNSIGNEDP. */
tree
signed_or_unsigned_type_for (int unsignedp, tree type)
{
- if (TREE_CODE (type) == INTEGER_TYPE && TYPE_UNSIGNED (type) == unsignedp)
+ if (ANY_INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) == unsignedp)
return type;
if (TREE_CODE (type) == VECTOR_TYPE)
{
tree inner = TREE_TYPE (type);
tree inner2 = signed_or_unsigned_type_for (unsignedp, inner);
if (!inner2)
return NULL_TREE;
if (inner == inner2)
return type;
return build_vector_type (inner2, TYPE_VECTOR_SUBPARTS (type));
}
+ if (TREE_CODE (type) == COMPLEX_TYPE)
+ {
+ tree inner = TREE_TYPE (type);
+ tree inner2 = signed_or_unsigned_type_for (unsignedp, inner);
+ if (!inner2)
+ return NULL_TREE;
+ if (inner == inner2)
+ return type;
+ return build_complex_type (inner2);
+ }
+
if (!INTEGRAL_TYPE_P (type)
&& !POINTER_TYPE_P (type)
&& TREE_CODE (type) != OFFSET_TYPE)
return NULL_TREE;
return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp);
}
/* If TYPE is an integral or pointer type, return an integer type with
the same precision which is unsigned, or itself if TYPE is already an