X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fc-common.c;h=b94ac1b7037becc46a04e6ccdb66df1efe847dd0;hb=6a167a57b73f180e3bdb2482a43db877c73f3084;hp=3a97bd7aaf5f3e84d0f04177dc2c1ef1e366ea4a;hpb=2becf397b3c3164cb9ac3a6ee3bc2d0d2146715f;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/c-common.c b/gcc/c-common.c index 3a97bd7aaf5..b94ac1b7037 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2719,7 +2719,7 @@ c_common_signed_or_unsigned_type (int unsignedp, tree type) #define TYPE_OK(node) \ (TYPE_MODE (type) == TYPE_MODE (node) \ - && (c_dialect_cxx () || TYPE_PRECISION (type) == TYPE_PRECISION (node))) + && TYPE_PRECISION (type) == TYPE_PRECISION (node)) if (TYPE_OK (signed_char_type_node)) return unsignedp ? unsigned_char_type_node : signed_char_type_node; if (TYPE_OK (integer_type_node)) @@ -2749,10 +2749,7 @@ c_common_signed_or_unsigned_type (int unsignedp, tree type) return unsignedp ? unsigned_intQI_type_node : intQI_type_node; #undef TYPE_OK - if (c_dialect_cxx ()) - return type; - else - return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp); + return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp); } /* Build a bit-field integer type for the given WIDTH and UNSIGNEDP. */ @@ -6547,7 +6544,8 @@ handle_vector_size_attribute (tree *node, tree name, tree args, || (!SCALAR_FLOAT_MODE_P (orig_mode) && GET_MODE_CLASS (orig_mode) != MODE_INT && !ALL_SCALAR_FIXED_POINT_MODE_P (orig_mode)) - || !host_integerp (TYPE_SIZE_UNIT (type), 1)) + || !host_integerp (TYPE_SIZE_UNIT (type), 1) + || TREE_CODE (type) == BOOLEAN_TYPE) { error ("invalid vector type for attribute %qE", name); return NULL_TREE; @@ -8062,7 +8060,7 @@ warn_array_subscript_with_type_char (tree index) void warn_about_parentheses (enum tree_code code, - enum tree_code code_left, tree ARG_UNUSED (arg_left), + enum tree_code code_left, tree arg_left, enum tree_code code_right, tree arg_right) { if (!warn_parentheses) @@ -8119,7 +8117,7 @@ warn_about_parentheses (enum tree_code code, /* Check cases like !x | y */ else if (code_left == TRUTH_NOT_EXPR && !APPEARS_TO_BE_BOOLEAN_EXPR_P (code_right, arg_right)) - warning (OPT_Wparentheses, "suggest parentheses around operand of" + warning (OPT_Wparentheses, "suggest parentheses around operand of " "% or change %<|%> to %<||%> or % to %<~%>"); return; @@ -8152,7 +8150,7 @@ warn_about_parentheses (enum tree_code code, /* Check cases like !x & y */ else if (code_left == TRUTH_NOT_EXPR && !APPEARS_TO_BE_BOOLEAN_EXPR_P (code_right, arg_right)) - warning (OPT_Wparentheses, "suggest parentheses around operand of" + warning (OPT_Wparentheses, "suggest parentheses around operand of " "% or change %<&%> to %<&&%> or % to %<~%>"); return; @@ -8172,9 +8170,11 @@ warn_about_parentheses (enum tree_code code, default: if (TREE_CODE_CLASS (code) == tcc_comparison && ((TREE_CODE_CLASS (code_left) == tcc_comparison - && code_left != NE_EXPR && code_left != EQ_EXPR) + && code_left != NE_EXPR && code_left != EQ_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg_left))) || (TREE_CODE_CLASS (code_right) == tcc_comparison - && code_right != NE_EXPR && code_right != EQ_EXPR))) + && code_right != NE_EXPR && code_right != EQ_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg_right))))) warning (OPT_Wparentheses, "comparisons like % do not " "have their mathematical meaning"); return; @@ -8241,7 +8241,7 @@ warn_for_sign_compare (location_t location, && TREE_CODE (TREE_TYPE (orig_op0)) == ENUMERAL_TYPE && TREE_CODE (TREE_TYPE (orig_op1)) == ENUMERAL_TYPE && TYPE_MAIN_VARIANT (TREE_TYPE (orig_op0)) - != TYPE_MAIN_VARIANT (TREE_TYPE (orig_op1))) + != TYPE_MAIN_VARIANT (TREE_TYPE (orig_op1))) { warning_at (location, OPT_Wsign_compare, "comparison between types %qT and %qT", @@ -8258,9 +8258,9 @@ warn_for_sign_compare (location_t location, /* OK */; else { - tree sop, uop; + tree sop, uop, base_type; bool ovf; - + if (op0_signed) sop = orig_op0, uop = orig_op1; else @@ -8268,6 +8268,8 @@ warn_for_sign_compare (location_t location, STRIP_TYPE_NOPS (sop); STRIP_TYPE_NOPS (uop); + base_type = (TREE_CODE (result_type) == COMPLEX_TYPE + ? TREE_TYPE (result_type) : result_type); /* Do not warn if the signed quantity is an unsuffixed integer literal (or some static constant expression involving such @@ -8280,7 +8282,7 @@ warn_for_sign_compare (location_t location, in the result if the result were signed. */ else if (TREE_CODE (uop) == INTEGER_CST && (resultcode == EQ_EXPR || resultcode == NE_EXPR) - && int_fits_type_p (uop, c_common_signed_type (result_type))) + && int_fits_type_p (uop, c_common_signed_type (base_type))) /* OK */; /* In C, do not warn if the unsigned quantity is an enumeration constant and its maximum value would fit in the result if the @@ -8288,7 +8290,7 @@ warn_for_sign_compare (location_t location, else if (!c_dialect_cxx() && TREE_CODE (uop) == INTEGER_CST && TREE_CODE (TREE_TYPE (uop)) == ENUMERAL_TYPE && int_fits_type_p (TYPE_MAX_VALUE (TREE_TYPE (uop)), - c_common_signed_type (result_type))) + c_common_signed_type (base_type))) /* OK */; else warning_at (location,