From: Martin Sebor Date: Wed, 24 May 2017 22:07:21 +0000 (+0000) Subject: PR c/80731 - poor -Woverflow warnings X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3cd211af9989ca33f08c9d9d7c29ba7cb208b645;p=gcc.git PR c/80731 - poor -Woverflow warnings gcc/c-family/ChangeLog: PR c/80731 * c-common.h (unsafe_conversion_p): Add a function argument. * c-common.c (unsafe_conversion_p): Same. Add type names and values to diagnostics. (scalar_to_vector): Adjust. * c-warn.c (constant_expression_error): Add a function argument. Add type names and values to diagnostics. (conversion_warning): Add a function argument. Add type names and values to diagnostics. (warnings_for_convert_and_check): Same. gcc/c/ChangeLog: PR c/80731 * c-fold.c (c_fully_fold_internal): Adjust. * c-typeck.c (parser_build_unary_op): Adjust. gcc/cp/ChangeLog: PR c/80731 * call.c (fully_fold_internal): Adjust. gcc/testsuite/ChangeLog: PR c/80731 * c-c++-common/Wfloat-conversion.c: Adjust. * c-c++-common/dfp/convert-int-saturate.c: Same. * c-c++-common/pr68657-1.c: Same. * g++.dg/ext/utf-cvt.C: Same. * g++.dg/ext/utf16-4.C: Same. * g++.dg/warn/Wconversion-real-integer-3.C: Same. * g++.dg/warn/Wconversion-real-integer2.C: Same. * g++.dg/warn/Wconversion3.C: Same. * g++.dg/warn/Wconversion4.C: Same. * g++.dg/warn/Wsign-conversion.C: Same. * g++.dg/warn/overflow-warn-1.C: Same. * g++.dg/warn/overflow-warn-3.C: Same. * g++.dg/warn/overflow-warn-4.C: Same. * g++.dg/warn/pr35635.C: Same. * g++.old-deja/g++.mike/enum1.C: Same. * gcc.dg/Wconversion-3.c: Same. * gcc.dg/Wconversion-5.c: Same. * gcc.dg/Wconversion-complex-c99.c: Same. * gcc.dg/Wconversion-complex-gnu.c: Same. * gcc.dg/Wconversion-integer.c: Same. * gcc.dg/Wsign-conversion.c: Same. * gcc.dg/bitfld-2.c: Same. * gcc.dg/c90-const-expr-11.c: Same. * gcc.dg/c90-const-expr-7.c: Same. * gcc.dg/c99-const-expr-7.c: Same. * gcc.dg/overflow-warn-1.c: Same. * gcc.dg/overflow-warn-2.c: Same. * gcc.dg/overflow-warn-3.c: Same. * gcc.dg/overflow-warn-4.c: Same. * gcc.dg/overflow-warn-5.c: Same. * gcc.dg/overflow-warn-8.c: Same. * gcc.dg/overflow-warn-9.c: New test. * gcc.dg/pr35635.c: Adjust. * gcc.dg/pr59940.c: Same. * gcc.dg/pr59963-2.c: Same. * gcc.dg/pr60114.c: Same. * gcc.dg/switch-warn-2.c: Same. * gcc.dg/utf-cvt.c: Same. * gcc.dg/utf16-4.c: Same. From-SVN: r248431 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 4419f207e5c..83c000baabd 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,16 @@ +2017-05-24 Martin Sebor + + PR c/80731 + * c-common.h (unsafe_conversion_p): Add a function argument. + * c-common.c (unsafe_conversion_p): Same. + Add type names and values to diagnostics. + (scalar_to_vector): Adjust. + * c-warn.c (constant_expression_error): Add a function argument. + Add type names and values to diagnostics. + (conversion_warning): Add a function argument. + Add type names and values to diagnostics. + (warnings_for_convert_and_check): Same. + 2017-05-19 Jason Merrill * c-warn.c (match_case_to_enum_1): Don't warn about enums with no diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 5f4488a9080..708fbe51919 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1227,16 +1227,24 @@ int_safely_convertible_to_real_p (const_tree from_type, const_tree to_type) can return SAFE_CONVERSION (zero) in that case. Function can produce signedness warnings if PRODUCE_WARNS is true. + RESULT, when non-null is the result of the conversion. When constant + it is included in the text of diagnostics. + Function allows conversions from complex constants to non-complex types, provided that imaginary part is zero and real part can be safely converted to TYPE. */ enum conversion_safety -unsafe_conversion_p (location_t loc, tree type, tree expr, bool produce_warns) +unsafe_conversion_p (location_t loc, tree type, tree expr, tree result, + bool produce_warns) { enum conversion_safety give_warning = SAFE_CONVERSION; /* is 0 or false */ tree expr_type = TREE_TYPE (expr); - loc = expansion_point_location_if_in_system_header (loc); + + bool cstresult = (result + && TREE_CODE_CLASS (TREE_CODE (result)) == tcc_constant); + + loc = expansion_point_location_if_in_system_header (loc); if (TREE_CODE (expr) == REAL_CST || TREE_CODE (expr) == INTEGER_CST) { @@ -1262,14 +1270,31 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, bool produce_warns) && tree_int_cst_sgn (expr) < 0) { if (produce_warns) - warning_at (loc, OPT_Wsign_conversion, "negative integer" - " implicitly converted to unsigned type"); + { + if (cstresult) + warning_at (loc, OPT_Wsign_conversion, + "unsigned conversion from %qT to %qT " + "changes value from %qE to %qE", + expr_type, type, expr, result); + else + warning_at (loc, OPT_Wsign_conversion, + "unsigned conversion from %qT to %qT " + "changes the value of %qE", + expr_type, type, expr); + } } else if (!TYPE_UNSIGNED (type) && TYPE_UNSIGNED (expr_type)) { - if (produce_warns) - warning_at (loc, OPT_Wsign_conversion, "conversion of unsigned" - " constant value to negative integer"); + if (cstresult) + warning_at (loc, OPT_Wsign_conversion, + "signed conversion from %qT to %qT changes " + "value from %qE to %qE", + expr_type, type, expr, result); + else + warning_at (loc, OPT_Wsign_conversion, + "signed conversion from %qT to %qT changes " + "the value of %qE", + expr_type, type, expr); } else give_warning = UNSAFE_OTHER; @@ -1308,7 +1333,7 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, bool produce_warns) with different type of EXPR, but it is still safe, because when EXPR is a constant, it's type is not used in text of generated warnings (otherwise they could sound misleading). */ - return unsafe_conversion_p (loc, type, TREE_REALPART (expr), + return unsafe_conversion_p (loc, type, TREE_REALPART (expr), result, produce_warns); /* Conversion from complex constant with non-zero imaginary part. */ else @@ -1328,9 +1353,10 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, bool produce_warns) Possible solution: add a separate function for checking constants and combine result of two calls appropriately. */ enum conversion_safety re_safety = - unsafe_conversion_p (loc, type, TREE_REALPART (expr), false); + unsafe_conversion_p (loc, type, TREE_REALPART (expr), + result, false); enum conversion_safety im_safety = - unsafe_conversion_p (loc, type, imag_part, false); + unsafe_conversion_p (loc, type, imag_part, result, false); /* Merge the results into appropriate single warning. */ @@ -7654,7 +7680,8 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, if (TREE_CODE (type0) == INTEGER_TYPE && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE) { - if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0, false)) + if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0, + NULL_TREE, false)) { if (complain) error_at (loc, "conversion of scalar %qT to vector %qT " @@ -7702,7 +7729,8 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, if (TREE_CODE (type0) == INTEGER_TYPE && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE) { - if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0, false)) + if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0, + NULL_TREE, false)) { if (complain) error_at (loc, "conversion of scalar %qT to vector %qT " @@ -7717,7 +7745,8 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, || TREE_CODE (type0) == INTEGER_TYPE) && SCALAR_FLOAT_TYPE_P (TREE_TYPE (type1))) { - if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0, false)) + if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0, + NULL_TREE, false)) { if (complain) error_at (loc, "conversion of scalar %qT to vector %qT " diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 502dc2f95cd..79072e6a8b7 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -832,7 +832,7 @@ extern tree c_common_signed_type (tree); extern tree c_common_signed_or_unsigned_type (int, tree); extern void c_common_init_ts (void); extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int); -extern enum conversion_safety unsafe_conversion_p (location_t, tree, tree, +extern enum conversion_safety unsafe_conversion_p (location_t, tree, tree, tree, bool); extern bool decl_with_nonnull_addr_p (const_tree); extern tree c_fully_fold (tree, bool, bool *); @@ -1483,7 +1483,7 @@ extern bool cilk_recognize_spawn (tree, tree *); /* In c-warn.c. */ extern void constant_expression_warning (tree); extern void constant_expression_error (tree); -extern void overflow_warning (location_t, tree); +extern void overflow_warning (location_t, tree, tree = NULL_TREE); extern void warn_logical_operator (location_t, enum tree_code, tree, enum tree_code, tree, enum tree_code, tree); extern void warn_tautological_cmp (location_t, enum tree_code, tree, tree); diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 897115612a0..012675bf6e9 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -63,8 +63,9 @@ constant_expression_error (tree value) error ("overflow in constant expression"); } -/* Print a warning if an expression had overflow in folding and its - operands hadn't. +/* Print a warning if an expression result VALUE had an overflow + in folding and its operands hadn't. EXPR, which may be null, is + the operand of the expression. Invoke this function on every expression that (1) appears in the source code, and @@ -75,42 +76,74 @@ constant_expression_error (tree value) already overflowed. */ void -overflow_warning (location_t loc, tree value) +overflow_warning (location_t loc, tree value, tree expr) { if (c_inhibit_evaluation_warnings != 0) return; + const char *warnfmt = NULL; + switch (TREE_CODE (value)) { case INTEGER_CST: - warning_at (loc, OPT_Woverflow, "integer overflow in expression"); + warnfmt = (expr + ? G_("integer overflow in expression %qE of type %qT " + "results in %qE") + : G_("integer overflow in expression of type %qT " + "results in %qE")); break; case REAL_CST: - warning_at (loc, OPT_Woverflow, - "floating point overflow in expression"); + warnfmt = (expr + ? G_ ("floating point overflow in expression %qE " + "of type %qT results in %qE") + : G_ ("floating point overflow in expression of type %qT " + "results in %qE")); break; case FIXED_CST: - warning_at (loc, OPT_Woverflow, "fixed-point overflow in expression"); + warnfmt = (expr + ? G_("fixed-point overflow in expression %qE of type %qT " + "results in %qE") + : G_("fixed-point overflow in expression of type %qT " + "results in %qE")); break; case VECTOR_CST: - warning_at (loc, OPT_Woverflow, "vector overflow in expression"); + warnfmt = (expr + ? G_("vector overflow in expression %qE of type %qT " + "results in %qE") + : G_("vector overflow in expression of type %qT " + "results in %qE")); break; case COMPLEX_CST: if (TREE_CODE (TREE_REALPART (value)) == INTEGER_CST) - warning_at (loc, OPT_Woverflow, - "complex integer overflow in expression"); + warnfmt = (expr + ? G_("complex integer overflow in expression %qE " + "of type %qT results in %qE") + : G_("complex integer overflow in expression of type %qT " + "results in %qE")); else if (TREE_CODE (TREE_REALPART (value)) == REAL_CST) - warning_at (loc, OPT_Woverflow, - "complex floating point overflow in expression"); + warnfmt = (expr + ? G_("complex floating point overflow in expression %qE " + "of type %qT results in %qE") + : G_("complex floating point overflow in expression " + "of type %qT results in %qE")); + else + return; break; default: - break; + return; } + + if (expr) + warning_at (loc, OPT_Woverflow, warnfmt, expr, TREE_TYPE (expr), value); + else + warning_at (loc, OPT_Woverflow, warnfmt, TREE_TYPE (value), value); + + TREE_NO_WARNING (value) = 1; } /* Helper function for walk_tree. Unwrap C_MAYBE_CONST_EXPRs in an expression @@ -930,7 +963,7 @@ check_main_parameter_types (tree decl) This is a helper function for warnings_for_convert_and_check. */ static void -conversion_warning (location_t loc, tree type, tree expr) +conversion_warning (location_t loc, tree type, tree expr, tree result) { tree expr_type = TREE_TYPE (expr); enum conversion_safety conversion_kind; @@ -971,43 +1004,49 @@ conversion_warning (location_t loc, tree type, tree expr) case REAL_CST: case INTEGER_CST: case COMPLEX_CST: - conversion_kind = unsafe_conversion_p (loc, type, expr, true); - if (conversion_kind == UNSAFE_REAL) - warning_at (loc, OPT_Wfloat_conversion, - "conversion to %qT alters %qT constant value", - type, expr_type); - else if (conversion_kind) - warning_at (loc, OPT_Wconversion, - "conversion to %qT alters %qT constant value", - type, expr_type); - return; + { + conversion_kind = unsafe_conversion_p (loc, type, expr, result, true); + int warnopt; + if (conversion_kind == UNSAFE_REAL) + warnopt = OPT_Wfloat_conversion; + else if (conversion_kind) + warnopt = OPT_Wconversion; + else + break; + if (TREE_CODE_CLASS (TREE_CODE (result)) == tcc_constant) + warning_at (loc, warnopt, + "conversion from %qT to %qT changes value from %qE to %qE", + expr_type, type, expr, result); + else + warning_at (loc, warnopt, + "conversion from %qT to %qT changes the value of %qE", + expr_type, type, expr); + break; + } case COND_EXPR: - { + { /* In case of COND_EXPR, we do not care about the type of COND_EXPR, only about the conversion of each operand. */ tree op1 = TREE_OPERAND (expr, 1); tree op2 = TREE_OPERAND (expr, 2); - conversion_warning (loc, type, op1); - conversion_warning (loc, type, op2); + conversion_warning (loc, type, op1, result); + conversion_warning (loc, type, op2, result); return; } default: /* 'expr' is not a constant. */ - conversion_kind = unsafe_conversion_p (loc, type, expr, true); - if (conversion_kind == UNSAFE_REAL) - warning_at (loc, OPT_Wfloat_conversion, - "conversion to %qT from %qT may alter its value", - type, expr_type); - else if (conversion_kind == UNSAFE_IMAGINARY) - warning_at (loc, OPT_Wconversion, - "conversion to %qT from %qT discards imaginary component", - type, expr_type); - else if (conversion_kind) + conversion_kind = unsafe_conversion_p (loc, type, expr, result, true); + if (conversion_kind == UNSAFE_IMAGINARY) warning_at (loc, OPT_Wconversion, - "conversion to %qT from %qT may alter its value", - type, expr_type); + "conversion from %qT to to %qT discards imaginary " + "component", + expr_type, type); + else if (conversion_kind == UNSAFE_REAL || conversion_kind) + warning_at (loc, OPT_Wfloat_conversion, + "conversion from %qT to %qT may change value", + expr_type, type); } } @@ -1021,6 +1060,10 @@ warnings_for_convert_and_check (location_t loc, tree type, tree expr, { loc = expansion_point_location_if_in_system_header (loc); + bool cst = TREE_CODE_CLASS (TREE_CODE (result)) == tcc_constant; + + tree exprtype = TREE_TYPE (expr); + if (TREE_CODE (expr) == INTEGER_CST && (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == ENUMERAL_TYPE) @@ -1036,31 +1079,76 @@ warnings_for_convert_and_check (location_t loc, tree type, tree expr, /* This detects cases like converting -129 or 256 to unsigned char. */ if (!int_fits_type_p (expr, c_common_signed_type (type))) - warning_at (loc, OPT_Woverflow, - "large integer implicitly truncated to unsigned type"); + { + if (cst) + warning_at (loc, OPT_Woverflow, + (TYPE_UNSIGNED (exprtype) + ? G_("conversion from %qT to %qT " + "changes value from %qE to %qE") + : G_("unsigned conversion from %qT to %qT " + "changes value from %qE to %qE")), + exprtype, type, expr, result); + else + warning_at (loc, OPT_Woverflow, + (TYPE_UNSIGNED (exprtype) + ? G_("conversion from %qT to %qT " + "changes the value of %qE") + : G_("unsigned conversion from %qT to %qT " + "changes the value of %qE")), + exprtype, type, expr); + } else - conversion_warning (loc, type, expr); + conversion_warning (loc, type, expr, result); } else if (!int_fits_type_p (expr, c_common_unsigned_type (type))) - warning_at (loc, OPT_Woverflow, - "overflow in implicit constant conversion"); + { + if (cst) + warning_at (loc, OPT_Woverflow, + "overflow in conversion from %qT to %qT " + "changes value from %qE to %qE", + exprtype, type, expr, result); + else + warning_at (loc, OPT_Woverflow, + "overflow in conversion from %qT to %qT " + "changes the value of %qE", + exprtype, type, expr); + } /* No warning for converting 0x80000000 to int. */ else if (pedantic - && (TREE_CODE (TREE_TYPE (expr)) != INTEGER_TYPE - || TYPE_PRECISION (TREE_TYPE (expr)) + && (TREE_CODE (exprtype) != INTEGER_TYPE + || TYPE_PRECISION (exprtype) != TYPE_PRECISION (type))) - warning_at (loc, OPT_Woverflow, - "overflow in implicit constant conversion"); - + { + if (cst) + warning_at (loc, OPT_Woverflow, + "overflow in conversion from %qT to %qT " + "changes value from %qE to %qE", + exprtype, type, expr, result); + else + warning_at (loc, OPT_Woverflow, + "overflow in conversion from %qT to %qT " + "changes the value of %qE", + exprtype, type, expr); + } else - conversion_warning (loc, type, expr); + conversion_warning (loc, type, expr, result); } else if ((TREE_CODE (result) == INTEGER_CST || TREE_CODE (result) == FIXED_CST) && TREE_OVERFLOW (result)) - warning_at (loc, OPT_Woverflow, - "overflow in implicit constant conversion"); + { + if (cst) + warning_at (loc, OPT_Woverflow, + "overflow in conversion from %qT to %qT " + "chages value from %qE to %qE", + exprtype, type, expr, result); + else + warning_at (loc, OPT_Woverflow, + "overflow in conversion from %qT to %qT " + "chages the value of %qE", + exprtype, type, expr); + } else - conversion_warning (loc, type, expr); + conversion_warning (loc, type, expr, result); } /* Subroutines of c_do_switch_warnings, called via splay_tree_foreach. diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index cb04d4acb5a..d240298d4d8 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2017-05-24 Martin Sebor + + PR c/80731 + * c-fold.c (c_fully_fold_internal): Adjust. + * c-typeck.c (parser_build_unary_op): Adjust. + 2017-05-23 Thomas Schwinge * c-parser.c (OACC_KERNELS_CLAUSE_MASK): Add diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c index 2601224c847..0abc4acc37f 100644 --- a/gcc/c/c-fold.c +++ b/gcc/c/c-fold.c @@ -307,7 +307,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, if (TREE_OVERFLOW_P (ret) && !TREE_OVERFLOW_P (op0) && !TREE_OVERFLOW_P (op1)) - overflow_warning (EXPR_LOC_OR_LOC (expr, input_location), ret); + overflow_warning (EXPR_LOC_OR_LOC (expr, input_location), ret, expr); if (code == LSHIFT_EXPR && TREE_CODE (orig_op0) != INTEGER_CST && TREE_CODE (TREE_TYPE (orig_op0)) == INTEGER_TYPE @@ -428,7 +428,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, default: if (TREE_OVERFLOW_P (ret) && !TREE_OVERFLOW_P (op0)) - overflow_warning (EXPR_LOCATION (expr), ret); + overflow_warning (EXPR_LOCATION (expr), ret, op0); break; } goto out; diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 25b7dd60253..95a607a1e76 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -3588,7 +3588,7 @@ parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg) result.value = build_unary_op (loc, code, arg.value, false); if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value)) - overflow_warning (loc, result.value); + overflow_warning (loc, result.value, arg.value); } /* We are typically called when parsing a prefix token at LOC acting on diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 27716d3d382..f2828f8d7eb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-05-24 Martin Sebor + + PR c/80731 + * call.c (fully_fold_internal): Adjust. + 2017-05-24 Nathan Sidwell * cp-tree.h (ovl_skip_hidden): Declare. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f14c0fabcc5..6b13d6e4cd8 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4814,14 +4814,14 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, but the warnings (like Wsign-conversion) have already been given by the scalar build_conditional_expr_1. We still check unsafe_conversion_p to forbid truncating long long -> float. */ - if (unsafe_conversion_p (loc, stype, arg2, false)) + if (unsafe_conversion_p (loc, stype, arg2, NULL_TREE, false)) { if (complain & tf_error) error_at (loc, "conversion of scalar %qT to vector %qT " "involves truncation", arg2_type, vtype); return error_mark_node; } - if (unsafe_conversion_p (loc, stype, arg3, false)) + if (unsafe_conversion_p (loc, stype, arg3, NULL_TREE, false)) { if (complain & tf_error) error_at (loc, "conversion of scalar %qT to vector %qT " diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9308ae15ae8..003dfa1b2d7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,46 @@ +2017-05-24 Martin Sebor + + PR c/80731 + * c-c++-common/Wfloat-conversion.c: Adjust. + * c-c++-common/dfp/convert-int-saturate.c: Same. + * c-c++-common/pr68657-1.c: Same. + * g++.dg/ext/utf-cvt.C: Same. + * g++.dg/ext/utf16-4.C: Same. + * g++.dg/warn/Wconversion-real-integer-3.C: Same. + * g++.dg/warn/Wconversion-real-integer2.C: Same. + * g++.dg/warn/Wconversion3.C: Same. + * g++.dg/warn/Wconversion4.C: Same. + * g++.dg/warn/Wsign-conversion.C: Same. + * g++.dg/warn/overflow-warn-1.C: Same. + * g++.dg/warn/overflow-warn-3.C: Same. + * g++.dg/warn/overflow-warn-4.C: Same. + * g++.dg/warn/pr35635.C: Same. + * g++.old-deja/g++.mike/enum1.C: Same. + * gcc.dg/Wconversion-3.c: Same. + * gcc.dg/Wconversion-5.c: Same. + * gcc.dg/Wconversion-complex-c99.c: Same. + * gcc.dg/Wconversion-complex-gnu.c: Same. + * gcc.dg/Wconversion-integer.c: Same. + * gcc.dg/Wsign-conversion.c: Same. + * gcc.dg/bitfld-2.c: Same. + * gcc.dg/c90-const-expr-11.c: Same. + * gcc.dg/c90-const-expr-7.c: Same. + * gcc.dg/c99-const-expr-7.c: Same. + * gcc.dg/overflow-warn-1.c: Same. + * gcc.dg/overflow-warn-2.c: Same. + * gcc.dg/overflow-warn-3.c: Same. + * gcc.dg/overflow-warn-4.c: Same. + * gcc.dg/overflow-warn-5.c: Same. + * gcc.dg/overflow-warn-8.c: Same. + * gcc.dg/overflow-warn-9.c: New test. + * gcc.dg/pr35635.c: Adjust. + * gcc.dg/pr59940.c: Same. + * gcc.dg/pr59963-2.c: Same. + * gcc.dg/pr60114.c: Same. + * gcc.dg/switch-warn-2.c: Same. + * gcc.dg/utf-cvt.c: Same. + * gcc.dg/utf16-4.c: Same. + 2017-05-24 Jakub Jelinek * g++.dg/ext/integer-pack2.C: Require int32 effective target. diff --git a/gcc/testsuite/c-c++-common/Wfloat-conversion.c b/gcc/testsuite/c-c++-common/Wfloat-conversion.c index e872755902d..e9899bce12b 100644 --- a/gcc/testsuite/c-c++-common/Wfloat-conversion.c +++ b/gcc/testsuite/c-c++-common/Wfloat-conversion.c @@ -29,30 +29,30 @@ void h (void) double d = 0; long double ld = 0; - ffloat (3.1); /* { dg-warning "conversion to 'float' alters 'double' constant value" } */ - vfloat = 3.1; /* { dg-warning "conversion to 'float' alters 'double' constant value" } */ - ffloat (3.1L); /* { dg-warning "conversion to 'float' alters 'long double' constant value" } */ - vfloat = 3.1L; /* { dg-warning "conversion to 'float' alters 'long double' constant value" } */ - fdouble (3.1L); /* { dg-warning "conversion to 'double' alters 'long double' constant value" "" { target large_long_double } } */ - vdouble = 3.1L; /* { dg-warning "conversion to 'double' alters 'long double' constant value" "" { target large_long_double } } */ - ffloat (vdouble); /* { dg-warning "conversion to 'float' from 'double' may alter its value" } */ - vfloat = vdouble; /* { dg-warning "conversion to 'float' from 'double' may alter its value" } */ - ffloat (vlongdouble); /* { dg-warning "conversion to 'float' from 'long double' may alter its value" } */ - vfloat = vlongdouble; /* { dg-warning "conversion to 'float' from 'long double' may alter its value" } */ - fdouble (vlongdouble); /* { dg-warning "conversion to 'double' from 'long double' may alter its value" "" { target large_long_double } } */ - vdouble = vlongdouble; /* { dg-warning "conversion to 'double' from 'long double' may alter its value" "" { target large_long_double } } */ + ffloat (3.1); /* { dg-warning "conversion from .double. to .float. changes value" } */ + vfloat = 3.1; /* { dg-warning "conversion from .double. to .float. changes value" } */ + ffloat (3.1L); /* { dg-warning "conversion from .long double. to .float. changes value" } */ + vfloat = 3.1L; /* { dg-warning "conversion from .long double. to .float. changes value" } */ + fdouble (3.1L); /* { dg-warning "conversion from .long double. to .double. changes value" "" { target large_long_double } } */ + vdouble = 3.1L; /* { dg-warning "conversion from .long double. to .double. changes value" "" { target large_long_double } } */ + ffloat (vdouble); /* { dg-warning "conversion from .double. to .float. may change value" } */ + vfloat = vdouble; /* { dg-warning "conversion from .double. to .float. may change value" } */ + ffloat (vlongdouble); /* { dg-warning "conversion from .long double. to .float. may change value" } */ + vfloat = vlongdouble; /* { dg-warning "conversion from .long double. to .float. may change value" } */ + fdouble (vlongdouble); /* { dg-warning "conversion from .long double. to .double. may change value" } */ + vdouble = vlongdouble; /* { dg-warning "conversion from .long double. to .double. may change value" } */ - fsi (3.1f); /* { dg-warning "conversion to 'int' alters 'float' constant value" } */ - si = 3.1f; /* { dg-warning "conversion to 'int' alters 'float' constant value" } */ - fsi (3.1); /* { dg-warning "conversion to 'int' alters 'double' constant value" } */ - si = 3.1; /* { dg-warning "conversion to 'int' alters 'double' constant value" } */ - fsi (d); /* { dg-warning "conversion to 'int' from 'double' may alter its value" } */ - si = d; /* { dg-warning "conversion to 'int' from 'double' may alter its value" } */ - ffloat (INT_MAX); /* { dg-warning "conversion to 'float' alters 'int' constant value" } */ - vfloat = INT_MAX; /* { dg-warning "conversion to 'float' alters 'int' constant value" } */ - ffloat (16777217); /* { dg-warning "conversion to 'float' alters 'int' constant value" } */ - vfloat = 16777217; /* { dg-warning "conversion to 'float' alters 'int' constant value" } */ + fsi (3.1f); /* { dg-warning "conversion from .float. to .int. changes value" } */ + si = 3.1f; /* { dg-warning "conversion from .float. to .int. changes value" } */ + fsi (3.1); /* { dg-warning "conversion from .double. to .int. changes value" } */ + si = 3.1; /* { dg-warning "conversion from .double. to .int. changes value" } */ + fsi (d); /* { dg-warning "conversion from .double. to .int. may change value" } */ + si = d; /* { dg-warning "conversion from .double. to .int. may change value" } */ + ffloat (INT_MAX); /* { dg-warning "conversion from .int. to .float. changes value" } */ + vfloat = INT_MAX; /* { dg-warning "conversion from .int. to .float. changes value" } */ + ffloat (16777217); /* { dg-warning "conversion from .int. to .float. changes value from .16777217." } */ + vfloat = 16777217; /* { dg-warning "conversion from .int. to .float. changes value from .16777217." } */ - sc = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion to 'signed char' alters 'double' constant value" } */ - uc = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion to 'unsigned char' alters 'double' constant value" } */ + sc = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion from .double. to .signed char. changes the value of .2\.1" } */ + uc = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion from .double. to .unsigned char. changes the value of .2\.1" } */ } diff --git a/gcc/testsuite/c-c++-common/dfp/convert-int-saturate.c b/gcc/testsuite/c-c++-common/dfp/convert-int-saturate.c index c92502d56ad..2d01f99468b 100644 --- a/gcc/testsuite/c-c++-common/dfp/convert-int-saturate.c +++ b/gcc/testsuite/c-c++-common/dfp/convert-int-saturate.c @@ -23,40 +23,40 @@ main () { /* Unsigned. */ - usi = DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + usi = DEC32_MAX; /* { dg-warning "overflow in conversion" } */ if (usi != UINT_MAX) FAILURE - usi = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + usi = DEC64_MAX; /* { dg-warning "overflow in conversion" } */ if (usi != UINT_MAX) FAILURE - usi = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + usi = DEC128_MAX; /* { dg-warning "overflow in conversion" } */ if (usi != UINT_MAX) FAILURE /* Signed. */ - si = DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + si = DEC32_MAX; /* { dg-warning "overflow in conversion" } */ if (si != INT_MAX) FAILURE - si = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + si = DEC64_MAX; /* { dg-warning "overflow in conversion" } */ if (si != INT_MAX) FAILURE - si = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + si = DEC128_MAX; /* { dg-warning "overflow in conversion" } */ if (si != INT_MAX) FAILURE - si = - DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + si = - DEC32_MAX; /* { dg-warning "overflow in conversion" } */ if (si != INT_MIN) FAILURE - si = - DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + si = - DEC64_MAX; /* { dg-warning "overflow in conversion" } */ if (si != INT_MIN) FAILURE - si = - DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + si = - DEC128_MAX; /* { dg-warning "overflow in conversion" } */ if (si != INT_MIN) FAILURE diff --git a/gcc/testsuite/c-c++-common/pr68657-1.c b/gcc/testsuite/c-c++-common/pr68657-1.c index 84f3e54a992..7b62b72e42d 100644 --- a/gcc/testsuite/c-c++-common/pr68657-1.c +++ b/gcc/testsuite/c-c++-common/pr68657-1.c @@ -5,14 +5,14 @@ void f1 (void) { - unsigned int a = -5; /* { dg-error "negative integer implicitly converted to unsigned type" } */ + unsigned int a = -5; /* { dg-error "unsigned conversion from .int. to .unsigned int. changes value from .-5. to .\[0-9\]+." } */ (void) a; } int f2 (void) { - return 3.1f; /* { dg-error "conversion to 'int' alters 'float' constant value" } */ + return 3.1f; /* { dg-error "conversion from .float. to .int. changes value" } */ } int f3 (char *); diff --git a/gcc/testsuite/g++.dg/ext/utf-cvt.C b/gcc/testsuite/g++.dg/ext/utf-cvt.C index 366c3d41796..929b7c71303 100644 --- a/gcc/testsuite/g++.dg/ext/utf-cvt.C +++ b/gcc/testsuite/g++.dg/ext/utf-cvt.C @@ -21,9 +21,9 @@ extern void full (unsigned long long); void m(char16_t c0, char32_t c1) { - f_c (c0); /* { dg-warning "alter its value" } */ - fsc (c0); /* { dg-warning "alter its value" } */ - fuc (c0); /* { dg-warning "alter its value" } */ + f_c (c0); /* { dg-warning "conversion from .char16_t. to .char. may change value" } */ + fsc (c0); /* { dg-warning "change value" } */ + fuc (c0); /* { dg-warning "change value" } */ f_s (c0); /* { dg-warning "change the sign" } */ fss (c0); /* { dg-warning "change the sign" } */ fus (c0); @@ -37,12 +37,12 @@ void m(char16_t c0, char32_t c1) fsll (c0); full (c0); - f_c (c1); /* { dg-warning "alter its value" } */ - fsc (c1); /* { dg-warning "alter its value" } */ - fuc (c1); /* { dg-warning "alter its value" } */ - f_s (c1); /* { dg-warning "alter its value" } */ - fss (c1); /* { dg-warning "alter its value" } */ - fus (c1); /* { dg-warning "alter its value" } */ + f_c (c1); /* { dg-warning "change value" } */ + fsc (c1); /* { dg-warning "change value" } */ + fuc (c1); /* { dg-warning "change value" } */ + f_s (c1); /* { dg-warning "change value" } */ + fss (c1); /* { dg-warning "change value" } */ + fus (c1); /* { dg-warning "change value" } */ f_i (c1); /* { dg-warning "change the sign" } */ fsi (c1); /* { dg-warning "change the sign" } */ fui (c1); diff --git a/gcc/testsuite/g++.dg/ext/utf16-4.C b/gcc/testsuite/g++.dg/ext/utf16-4.C index e8d6531b20d..2c4377cea5d 100644 --- a/gcc/testsuite/g++.dg/ext/utf16-4.C +++ b/gcc/testsuite/g++.dg/ext/utf16-4.C @@ -10,9 +10,9 @@ const static char16_t c2 = u'\U00064321'; /* { dg-warning "constant too long" } const static char16_t c3 = 'a'; const static char16_t c4 = U'a'; const static char16_t c5 = U'\u2029'; -const static char16_t c6 = U'\U00064321'; /* { dg-warning "implicitly truncated" } */ +const static char16_t c6 = U'\U00064321'; /* { dg-warning "conversion from .char32_t. to .char16_t. changes value from .410401. to .17185." } */ const static char16_t c7 = L'a'; const static char16_t c8 = L'\u2029'; -const static char16_t c9 = L'\U00064321'; /* { dg-warning "implicitly truncated" "" { target { 4byte_wchar_t } } } */ +const static char16_t c9 = L'\U00064321'; /* { dg-warning "unsigned conversion from .wchar_t. to .char16_t. changes value from .410401. to .17185." "" { target { 4byte_wchar_t } } } */ /* { dg-warning "constant too long" "" { target { ! 4byte_wchar_t } } .-1 } */ int main () {} diff --git a/gcc/testsuite/g++.dg/warn/Wconversion-real-integer-3.C b/gcc/testsuite/g++.dg/warn/Wconversion-real-integer-3.C index 775c88c3fad..8b7574dbbc8 100644 --- a/gcc/testsuite/g++.dg/warn/Wconversion-real-integer-3.C +++ b/gcc/testsuite/g++.dg/warn/Wconversion-real-integer-3.C @@ -16,5 +16,5 @@ void h (void) // the locus that inside the source code here, at the relevant // line below, even with -ftrack-macro-expansion. We don't want // it to point to the any locus that is inside the system header. - vfloat = INT_MAX; // { dg-warning "conversion to .float. alters .int. constant value" } + vfloat = INT_MAX; // { dg-warning "conversion from .int. to .float. changes value from .2147483647. to " } } diff --git a/gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C b/gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C index 7e39d5fa747..7386525ae84 100644 --- a/gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C +++ b/gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C @@ -23,7 +23,7 @@ // // That is more useful. -#define INT_MAX __INT_MAX__ // { dg-warning "17: conversion to .float. alters .int. constant value" } +#define INT_MAX __INT_MAX__ // { dg-warning "17: conversion from 'int' to 'float' changes value from .2147483647. to " } float vfloat; diff --git a/gcc/testsuite/g++.dg/warn/Wconversion3.C b/gcc/testsuite/g++.dg/warn/Wconversion3.C index 24202b7d98e..71604f9a8e6 100644 --- a/gcc/testsuite/g++.dg/warn/Wconversion3.C +++ b/gcc/testsuite/g++.dg/warn/Wconversion3.C @@ -19,9 +19,9 @@ void test1 (void) unsigned char f = (int) uc; signed char g = (int) sc; unsigned char h = (unsigned int) (short int) uc; - signed char i = (int) (unsigned short int) sc; // { dg-warning "may alter its value" } - unsigned char j = (unsigned int) (short int) us; // { dg-warning "may alter its value" } - signed char k = (int) (unsigned short int) ss; // { dg-warning "may alter its value" } + signed char i = (int) (unsigned short int) sc; // { dg-warning "may change value" } + unsigned char j = (unsigned int) (short int) us; // { dg-warning "may change value" } + signed char k = (int) (unsigned short int) ss; // { dg-warning "may change value" } } void test2 (void) diff --git a/gcc/testsuite/g++.dg/warn/Wconversion4.C b/gcc/testsuite/g++.dg/warn/Wconversion4.C index 83daaa06928..d1e0f4ad4ed 100644 --- a/gcc/testsuite/g++.dg/warn/Wconversion4.C +++ b/gcc/testsuite/g++.dg/warn/Wconversion4.C @@ -7,7 +7,7 @@ class Test { void eval() { - foo(bar()); // { dg-warning "may alter its value" } + foo(bar()); // { dg-warning "may change value" } } unsigned int bar() const diff --git a/gcc/testsuite/g++.dg/warn/Wsign-conversion.C b/gcc/testsuite/g++.dg/warn/Wsign-conversion.C index f6a0cccdffc..3fa71226b48 100644 --- a/gcc/testsuite/g++.dg/warn/Wsign-conversion.C +++ b/gcc/testsuite/g++.dg/warn/Wsign-conversion.C @@ -40,26 +40,26 @@ void h (int x) fuc ('A'); uc = 'A'; - uc = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = x ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = x ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = x ? INT_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = 1U * -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = ui + INT_MIN; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = ui ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + uc = x ? 1U : -1; /* { dg-warning "unsigned conversion" } */ + uc = x ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion" } */ + uc = x ? 1 : -1; /* { dg-warning "unsigned conversion" } */ + uc = x ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion" } */ + ui = x ? 1U : -1; /* { dg-warning "unsigned conversion" } */ + ui = x ? INT_MIN : 1U; /* { dg-warning "unsigned conversion" } */ + ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion" } */ + ui = 1U * -1; /* { dg-warning "unsigned conversion" } */ + ui = ui + INT_MIN; /* { dg-warning "unsigned conversion" } */ + ui = x ? 1 : -1; /* { dg-warning "unsigned conversion" } */ + ui = ui ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion" } */ - fuc (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fui (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fuc ('\xa0'); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fui ('\xa0');/* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + fuc (-1); /* { dg-warning "unsigned conversion" } */ + uc = -1; /* { dg-warning "unsigned conversion" } */ + fui (-1); /* { dg-warning "unsigned conversion" } */ + ui = -1; /* { dg-warning "unsigned conversion" } */ + fuc ('\xa0'); /* { dg-warning "unsigned conversion" } */ + uc = '\xa0'; /* { dg-warning "unsigned conversion" } */ + fui ('\xa0');/* { dg-warning "unsigned conversion" } */ + ui = '\xa0'; /* { dg-warning "unsigned conversion" } */ fsi (0x80000000); /* { dg-warning "conversion" } */ si = 0x80000000; /* { dg-warning "conversion" } */ @@ -91,5 +91,5 @@ void h (int x) ui = sc; /* { dg-warning "conversion" } */ } -unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "negative integer implicitly converted to unsigned type" } */ +unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "unsigned conversion" } */ diff --git a/gcc/testsuite/g++.dg/warn/overflow-warn-1.C b/gcc/testsuite/g++.dg/warn/overflow-warn-1.C index 314e3518270..9177373a939 100644 --- a/gcc/testsuite/g++.dg/warn/overflow-warn-1.C +++ b/gcc/testsuite/g++.dg/warn/overflow-warn-1.C @@ -102,14 +102,14 @@ void h2 (void) { fsc (SCHAR_MAX + 1); - fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ fsc (UCHAR_MAX); - fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ fuc (-1); - fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ fuc (SCHAR_MIN); - fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ - fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ } void fui (unsigned int); diff --git a/gcc/testsuite/g++.dg/warn/overflow-warn-3.C b/gcc/testsuite/g++.dg/warn/overflow-warn-3.C index b319660f68f..91afd01e09b 100644 --- a/gcc/testsuite/g++.dg/warn/overflow-warn-3.C +++ b/gcc/testsuite/g++.dg/warn/overflow-warn-3.C @@ -100,15 +100,15 @@ void fsc (signed char); void h2 (void) { - fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ fuc (-1); - fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ fuc (SCHAR_MIN); - fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ - fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ } void fui (unsigned int); diff --git a/gcc/testsuite/g++.dg/warn/overflow-warn-4.C b/gcc/testsuite/g++.dg/warn/overflow-warn-4.C index dfe87411507..3f0bf1f7240 100644 --- a/gcc/testsuite/g++.dg/warn/overflow-warn-4.C +++ b/gcc/testsuite/g++.dg/warn/overflow-warn-4.C @@ -103,15 +103,15 @@ void fsc (signed char); void h2 (void) { - fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion" } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion" } */ + fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion" } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion" } */ fuc (-1); - fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ fuc (SCHAR_MIN); - fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ - fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion" } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion" } */ } void fui (unsigned int); diff --git a/gcc/testsuite/g++.dg/warn/pr35635.C b/gcc/testsuite/g++.dg/warn/pr35635.C index 19345c51162..628c0502a9c 100644 --- a/gcc/testsuite/g++.dg/warn/pr35635.C +++ b/gcc/testsuite/g++.dg/warn/pr35635.C @@ -63,7 +63,7 @@ void func3() warn. */ uchar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */ uchar_x = bar != 0 - ? (unsigned char) 1024 /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + ? (unsigned char) 1024 /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-1." } */ : -1; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/enum1.C b/gcc/testsuite/g++.old-deja/g++.mike/enum1.C index 35b1df0898a..2f7a6dd438a 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/enum1.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/enum1.C @@ -8,4 +8,4 @@ struct Type { void setBTK(); }; -void Type::setBTK() { kind = DTK; } // { dg-warning "truncate" } +void Type::setBTK() { kind = DTK; } // { dg-warning "conversion from '\[^\n\r]+' to .unsigned char:1. changes value from" } diff --git a/gcc/testsuite/gcc.dg/Wconversion-3.c b/gcc/testsuite/gcc.dg/Wconversion-3.c index d45749d69c0..d102d169d02 100644 --- a/gcc/testsuite/gcc.dg/Wconversion-3.c +++ b/gcc/testsuite/gcc.dg/Wconversion-3.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ /* { dg-options "-O2 -Wconversion" } */ -unsigned f(unsigned a) { return a + -1; } /* { dg-warning "negative" } */ +unsigned f(unsigned a) { return a + -1; } /* { dg-warning "conversion" } */ diff --git a/gcc/testsuite/gcc.dg/Wconversion-5.c b/gcc/testsuite/gcc.dg/Wconversion-5.c index be749a9a65f..e54fe1a8ace 100644 --- a/gcc/testsuite/gcc.dg/Wconversion-5.c +++ b/gcc/testsuite/gcc.dg/Wconversion-5.c @@ -19,9 +19,9 @@ void test1 (void) unsigned char f = (int) uc; signed char g = (int) sc; unsigned char h = (unsigned int) (short int) uc; - signed char i = (int) (unsigned short int) sc; /* { dg-warning "may alter its value" "" { target { int32plus } } } */ - unsigned char j = (unsigned int) (short int) us; /* { dg-warning "may alter its value" } */ - signed char k = (int) (unsigned short int) ss; /* { dg-warning "may alter its value" } */ + signed char i = (int) (unsigned short int) sc; /* { dg-warning "conversion from .int. to .signed char. may change value" "" { target { int32plus } } } */ + unsigned char j = (unsigned int) (short int) us; /* { dg-warning "may change value" } */ + signed char k = (int) (unsigned short int) ss; /* { dg-warning "may change value" } */ } void test2 (void) diff --git a/gcc/testsuite/gcc.dg/Wconversion-complex-c99.c b/gcc/testsuite/gcc.dg/Wconversion-complex-c99.c index 0e6c39022f4..bc7439de85b 100644 --- a/gcc/testsuite/gcc.dg/Wconversion-complex-c99.c +++ b/gcc/testsuite/gcc.dg/Wconversion-complex-c99.c @@ -63,10 +63,10 @@ var_complex_narrowing (void) double _Complex doublec = 0.; vdoublec = floatc; - vfloatc = doublec; /* { dg-warning "float-conversion" } */ + vfloatc = doublec; /* { dg-warning "conversion from .complex double. to .complex float. may change value" } */ fdoublec (floatc); - ffloatc (doublec); /* { dg-warning "float-conversion" } */ + ffloatc (doublec); /* { dg-warning "conversion from .complex double. to .complex float. may change value" } */ } /* Check implicit conversions of complex values to integers. */ diff --git a/gcc/testsuite/gcc.dg/Wconversion-complex-gnu.c b/gcc/testsuite/gcc.dg/Wconversion-complex-gnu.c index 3839a39bce4..80990cb6604 100644 --- a/gcc/testsuite/gcc.dg/Wconversion-complex-gnu.c +++ b/gcc/testsuite/gcc.dg/Wconversion-complex-gnu.c @@ -32,11 +32,11 @@ var_float_to_int (void) { double _Complex doublec = 0.; - fsic (doublec); /* { dg-warning "float-conversion" } */ - fuic (doublec); /* { dg-warning "float-conversion" } */ + fsic (doublec); /* { dg-warning "conversion" } */ + fuic (doublec); /* { dg-warning "conversion" } */ - vsic = doublec; /* { dg-warning "float-conversion" } */ - vuic = doublec; /* { dg-warning "float-conversion" } */ + vsic = doublec; /* { dg-warning "conversion" } */ + vuic = doublec; /* { dg-warning "conversion" } */ } /* Check implicit conversions of integer complex-domain values to integer @@ -75,9 +75,9 @@ const_float_to_int (void) vsic = 1. - 1.i; vuic = 1. + 1.i; - fsic (0.5 + 0.i); /* { dg-warning "float-conversion" } */ - vsic = 0.5 + 0.i; /* { dg-warning "float-conversion" } */ - fuic (0.5 + 0.i); /* { dg-warning "float-conversion" } */ + fsic (0.5 + 0.i); /* { dg-warning "conversion" } */ + vsic = 0.5 + 0.i; /* { dg-warning "conversion" } */ + fuic (0.5 + 0.i); /* { dg-warning "conversion" } */ } /* Check implicit conversions of integer complex-domain constants to integer @@ -96,8 +96,8 @@ const_complex_int_to_real_int (void) fui (UINT_MAX + 1ull + 0i); /* { dg-warning "conversion" } */ vui = UINT_MAX + 1ull + 0i; /* { dg-warning "conversion" } */ - ffloat (UINT_MAX + 0i); /* { dg-warning "float-conversion" } */ - vfloat = UINT_MAX + 0i; /* { dg-warning "float-conversion" } */ + ffloat (UINT_MAX + 0i); /* { dg-warning "conversion" } */ + vfloat = UINT_MAX + 0i; /* { dg-warning "conversion" } */ } void @@ -116,12 +116,12 @@ const_complex_int_narrowing (void) vuic = (UINT_MAX + 1ull) + 1i; /* { dg-warning "conversion" } */ vuic = (UINT_MAX + 1ull) + (UINT_MAX + 1ull) * 1i; /* { dg-warning "conversion" } */ - ffloatc (UINT_MAX * 1i); /* { dg-warning "float-conversion" } */ - ffloatc (UINT_MAX + 1i); /* { dg-warning "float-conversion" } */ - ffloatc (UINT_MAX + UINT_MAX * 1i); /* { dg-warning "float-conversion" } */ + ffloatc (UINT_MAX * 1i); /* { dg-warning "conversion" } */ + ffloatc (UINT_MAX + 1i); /* { dg-warning "conversion" } */ + ffloatc (UINT_MAX + UINT_MAX * 1i); /* { dg-warning "conversion" } */ - vfloatc = UINT_MAX * 1i; /* { dg-warning "float-conversion" } */ - vfloatc = UINT_MAX + 1i; /* { dg-warning "float-conversion" } */ - vfloatc = UINT_MAX + UINT_MAX * 1i; /* { dg-warning "float-conversion" } */ + vfloatc = UINT_MAX * 1i; /* { dg-warning "conversion" } */ + vfloatc = UINT_MAX + 1i; /* { dg-warning "conversion" } */ + vfloatc = UINT_MAX + UINT_MAX * 1i; /* { dg-warning "conversion" } */ } diff --git a/gcc/testsuite/gcc.dg/Wconversion-integer.c b/gcc/testsuite/gcc.dg/Wconversion-integer.c index dc13e8fab36..cf7745cf837 100644 --- a/gcc/testsuite/gcc.dg/Wconversion-integer.c +++ b/gcc/testsuite/gcc.dg/Wconversion-integer.c @@ -40,28 +40,28 @@ void h (int x) fuc ('A'); uc = 'A'; - uc = x ? 1U : -1; /* { dg-warning " conversion" "conversion" } */ - /* { dg-warning "negative integer implicitly converted to unsigned type" "implicit" { target *-*-* } .-1 } */ - uc = x ? SCHAR_MIN : 1U; /* { dg-warning " conversion" "conversion" } */ - /* { dg-warning "negative integer implicitly converted to unsigned type" "implicit" { target *-*-* } .-1 } */ - uc = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = x ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = x ? INT_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = 1U * -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = ui + INT_MIN; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = ui ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + uc = x ? 1U : -1; /* { dg-warning "conversion from .unsigned int. to .unsigned char." } */ + /* { dg-warning "unsigned conversion" "implicit" { target *-*-* } .-1 } */ + uc = x ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion" } */ + /* { dg-warning "conversion from .unsigned int. to .unsigned char." "implicit" { target *-*-* } .-1 } */ + uc = x ? 1 : -1; /* { dg-warning "signed conversion" } */ + uc = x ? SCHAR_MIN : 1; /* { dg-warning "signed conversion" } */ + ui = x ? 1U : -1; /* { dg-warning "signed conversion" } */ + ui = x ? INT_MIN : 1U; /* { dg-warning "signed conversion" } */ + ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "signed conversion" } */ + ui = 1U * -1; /* { dg-warning "signed conversion" } */ + ui = ui + INT_MIN; /* { dg-warning "signed conversion" } */ + ui = x ? 1 : -1; /* { dg-warning "signed conversion" } */ + ui = ui ? SCHAR_MIN : 1; /* { dg-warning "signed conversion" } */ - fuc (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fui (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fuc ('\xa0'); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fui ('\xa0');/* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + fuc (-1); /* { dg-warning "signed conversion" } */ + uc = -1; /* { dg-warning "signed conversion" } */ + fui (-1); /* { dg-warning "signed conversion" } */ + ui = -1; /* { dg-warning "signed conversion" } */ + fuc ('\xa0'); /* { dg-warning "signed conversion" } */ + uc = '\xa0'; /* { dg-warning "signed conversion" } */ + fui ('\xa0');/* { dg-warning "signed conversion" } */ + ui = '\xa0'; /* { dg-warning "signed conversion" } */ fsi (0x80000000); /* { dg-warning "conversion" } */ si = 0x80000000; /* { dg-warning "conversion" } */ @@ -93,6 +93,6 @@ void h (int x) ui = sc; /* { dg-warning "conversion" } */ } -unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "negative integer implicitly converted to unsigned type" } */ +unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "signed conversion" } */ diff --git a/gcc/testsuite/gcc.dg/Wsign-conversion.c b/gcc/testsuite/gcc.dg/Wsign-conversion.c index 0300850f904..bda61eb8bbf 100644 --- a/gcc/testsuite/gcc.dg/Wsign-conversion.c +++ b/gcc/testsuite/gcc.dg/Wsign-conversion.c @@ -40,28 +40,28 @@ void h (int x) fuc ('A'); uc = 'A'; - uc = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = x ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = x ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = x ? INT_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = 1U * -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = ui + INT_MIN; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = ui ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + uc = x ? 1U : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-1. to .\[0-9\]+." } */ + uc = x ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-\[0-9\]+. to .\[0-9\]+." } */ + uc = x ? 1 : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-1." } */ + uc = x ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-\[0-9\]+." } */ + ui = x ? 1U : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-1. to .\[0-9\]+." } */ + ui = x ? INT_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-\[0-9\]+. to .\[0-9\]+." } */ + ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */ + ui = 1U * -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */ + ui = ui + INT_MIN; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */ + ui = x ? 1 : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes the value of .-1." } */ + ui = ui ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes the value of " } */ - fuc (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fui (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fuc ('\xa0'); /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - uc = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fui ('\xa0');/* { dg-warning "negative integer implicitly converted to unsigned type" } */ - ui = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ - fsi (0x80000000); /* { dg-warning "conversion" } */ - si = 0x80000000; /* { dg-warning "conversion" } */ + fuc (-1); /* { dg-warning "unsigned conversion" } */ + uc = -1; /* { dg-warning "unsigned conversion" } */ + fui (-1); /* { dg-warning "unsigned conversion" } */ + ui = -1; /* { dg-warning "unsigned conversion" } */ + fuc ('\xa0'); /* { dg-warning "unsigned conversion" } */ + uc = '\xa0'; /* { dg-warning "unsigned conversion" } */ + fui ('\xa0');/* { dg-warning "unsigned conversion" } */ + ui = '\xa0'; /* { dg-warning "unsigned conversion" } */ + fsi (0x80000000); /* { dg-warning "signed conversion" } */ + si = 0x80000000; /* { dg-warning "signed conversion" } */ fsi (UINT_MAX - 1); /* { dg-warning "conversion" } */ @@ -85,12 +85,12 @@ void h (int x) uc = sc; /* { dg-warning "conversion" } */ fsi (ui); /* { dg-warning "conversion" } */ si = ui; /* { dg-warning "conversion" } */ - fui (si); /* { dg-warning "conversion" } */ - ui = si; /* { dg-warning "conversion" } */ + fui (si); /* { dg-warning "conversion" } */ + ui = si; /* { dg-warning "conversion" } */ fui (sc); /* { dg-warning "conversion" } */ ui = sc; /* { dg-warning "conversion" } */ } -unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "negative integer implicitly converted to unsigned type" } */ +unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value" } */ diff --git a/gcc/testsuite/gcc.dg/bitfld-2.c b/gcc/testsuite/gcc.dg/bitfld-2.c index e3f5f1bcc35..92cf2f6cc24 100644 --- a/gcc/testsuite/gcc.dg/bitfld-2.c +++ b/gcc/testsuite/gcc.dg/bitfld-2.c @@ -11,13 +11,13 @@ struct bf int b: 2; }; -struct bf p = {4, 0}; /* { dg-warning "truncated" } */ -struct bf q = {0, 2}; /* { dg-warning "overflow" } */ -struct bf r = {3, -2}; /* { dg-bogus "(truncated|overflow)" } */ +struct bf p = {4, 0}; /* { dg-warning "unsigned conversion from .int. to 'unsigned char:2' changes value from .4. to .0." } */ +struct bf q = {0, 2}; /* { dg-warning "overflow in conversion from .int. to .signed char:2. changes value from .2. to .-2." } */ +struct bf r = {3, -2}; /* { dg-bogus "(trunc|overflow)" } */ void foo () { - p.a = 4, p.b = 0; /* { dg-warning "truncated" } */ - q.a = 0, q.b = 2; /* { dg-warning "overflow" } */ - r.a = 3, r.b = -2; /* { dg-bogus "(truncated|overflow)" } */ + p.a = 4, p.b = 0; /* { dg-warning "unsigned conversion from .int. to .unsigned char:2. changes value from .4. to .0." } */ + q.a = 0, q.b = 2; /* { dg-warning "overflow in conversion from .int. to .signed char:2. changes value from .2. to .-2." } */ + r.a = 3, r.b = -2; /* { dg-bogus "(trunc|overflow)" } */ } diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-11.c b/gcc/testsuite/gcc.dg/c90-const-expr-11.c index 5cd704a8d73..e4f2aff7874 100644 --- a/gcc/testsuite/gcc.dg/c90-const-expr-11.c +++ b/gcc/testsuite/gcc.dg/c90-const-expr-11.c @@ -20,7 +20,7 @@ f (void) /* Overflow. */ struct t b = { INT_MAX + 1 }; /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ - struct t c = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */ + struct t c = { DBL_MAX }; /* { dg-warning "overflow in conversion from .double. to .int. chages value " } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ /* Bad operator outside sizeof. */ struct s d = { 1 ? 1.0 : atan (a.d) }; /* { dg-error "is not a constant expression|near initialization" } */ diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-7.c b/gcc/testsuite/gcc.dg/c90-const-expr-7.c index 56a147864eb..f423b005e20 100644 --- a/gcc/testsuite/gcc.dg/c90-const-expr-7.c +++ b/gcc/testsuite/gcc.dg/c90-const-expr-7.c @@ -6,10 +6,10 @@ #include -int a = DBL_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ +int a = DBL_MAX; /* { dg-warning "overflow in conversion" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ int b = (int) DBL_MAX; /* { dg-error "overflow" } */ -unsigned int c = -1.0; /* { dg-warning "overflow in implicit constant conversion" } */ +unsigned int c = -1.0; /* { dg-warning "overflow in conversion" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */ @@ -31,5 +31,5 @@ int h1 = (0 ? 0 >> -1: 0); int i = -1 << 0; -int j[1] = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */ +int j[1] = { DBL_MAX }; /* { dg-warning "overflow in conversion" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-7.c b/gcc/testsuite/gcc.dg/c99-const-expr-7.c index c663723c03a..bf23a4a4173 100644 --- a/gcc/testsuite/gcc.dg/c99-const-expr-7.c +++ b/gcc/testsuite/gcc.dg/c99-const-expr-7.c @@ -7,10 +7,10 @@ #include #include -int a = DBL_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ +int a = DBL_MAX; /* { dg-warning "overflow in conversion" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ int b = (int) DBL_MAX; /* { dg-error "overflow" } */ -unsigned int c = -1.0; /* { dg-warning "overflow in implicit constant conversion" } */ +unsigned int c = -1.0; /* { dg-warning "overflow in conversion" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */ @@ -33,7 +33,7 @@ int h1 = (0 ? 0 >> -1: 0); int i = -1 << 0; /* { dg-error "constant" "constant" { target *-*-* } .-1 } */ -int j[1] = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */ +int j[1] = { DBL_MAX }; /* { dg-warning "overflow in conversion" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ int array[2] = { [0 * (INT_MAX + 1)] = 0 }; /* { dg-warning "integer overflow in expression" } */ diff --git a/gcc/testsuite/gcc.dg/overflow-warn-1.c b/gcc/testsuite/gcc.dg/overflow-warn-1.c index 48185e90051..8eb322579cf 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-1.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-1.c @@ -85,14 +85,14 @@ void h2 (void) { fsc (SCHAR_MAX + 1); - fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value " } */ fsc (UCHAR_MAX); - fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value from " } */ fuc (-1); - fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ fuc (SCHAR_MIN); - fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ - fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ } void fui (unsigned int); diff --git a/gcc/testsuite/gcc.dg/overflow-warn-2.c b/gcc/testsuite/gcc.dg/overflow-warn-2.c index f77c20f9559..f048d6dae2a 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-2.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-2.c @@ -86,21 +86,21 @@ h2 (void) { fsc (SCHAR_MAX + 1); /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ - fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ fsc (UCHAR_MAX); /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ - fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from 'int' to 'signed char' changes value " } */ /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ fuc (-1); /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ - fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ fuc (SCHAR_MIN); /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ - fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */ /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ - fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */ } diff --git a/gcc/testsuite/gcc.dg/overflow-warn-3.c b/gcc/testsuite/gcc.dg/overflow-warn-3.c index 8bd190e1296..664011e401d 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-3.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-3.c @@ -91,15 +91,15 @@ void fsc (signed char); void h2 (void) { - fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value " } */ fuc (-1); - fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ fuc (SCHAR_MIN); - fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ - fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ } void fui (unsigned int); diff --git a/gcc/testsuite/gcc.dg/overflow-warn-4.c b/gcc/testsuite/gcc.dg/overflow-warn-4.c index a28cb56b30f..52677ce897a 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-4.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-4.c @@ -21,7 +21,7 @@ enum e { E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ /* Again, overflow in evaluated subexpression. */ - E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */ + E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression of type .int. results in .-\[0-9\]+." } */ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */ /* A cast does not constitute overflow in conversion. */ E7 = (char) INT_MAX @@ -91,15 +91,15 @@ void fsc (signed char); void h2 (void) { - fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */ - fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */ + fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */ + fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion" } */ + fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion" } */ + fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion" } */ fuc (-1); - fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */ fuc (SCHAR_MIN); - fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ - fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion" } */ + fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion" } */ } void fui (unsigned int); diff --git a/gcc/testsuite/gcc.dg/overflow-warn-5.c b/gcc/testsuite/gcc.dg/overflow-warn-5.c index 472d4a7cab1..b2c8dc31d95 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-5.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-5.c @@ -3,5 +3,5 @@ /* { dg-options "-Woverflow" } */ unsigned char rx_async(unsigned char p) { - return p & 512; /* { dg-warning "overflow in implicit constant conversion" } */ + return p & 512; /* { dg-warning "overflow in conversion from .int. to .unsigned char. chages value" } */ } diff --git a/gcc/testsuite/gcc.dg/overflow-warn-8.c b/gcc/testsuite/gcc.dg/overflow-warn-8.c index 43ecda0a56e..ace605517dc 100644 --- a/gcc/testsuite/gcc.dg/overflow-warn-8.c +++ b/gcc/testsuite/gcc.dg/overflow-warn-8.c @@ -7,7 +7,7 @@ void foo (int j) int i3 = 1 + INT_MAX; /* { dg-warning "integer overflow" } */ int i4 = +1 + INT_MAX; /* { dg-warning "integer overflow" } */ int i5 = (int)((double)1.0 + INT_MAX); - int i6 = (double)1.0 + INT_MAX; /* { dg-warning "overflow in implicit constant" } */ + int i6 = (double)1.0 + INT_MAX; /* { dg-warning "overflow in conversion from .double. to .int. chages value" } */ int i7 = 0 ? (int)(double)1.0 + INT_MAX : 1; int i8 = 1 ? 1 : (int)(double)1.0 + INT_MAX; int i9 = j ? (int)(double)1.0 + INT_MAX : 1; /* { dg-warning "integer overflow" } */ diff --git a/gcc/testsuite/gcc.dg/overflow-warn-9.c b/gcc/testsuite/gcc.dg/overflow-warn-9.c new file mode 100644 index 00000000000..88d6afb5955 --- /dev/null +++ b/gcc/testsuite/gcc.dg/overflow-warn-9.c @@ -0,0 +1,64 @@ +/* PR c/80731 - poor -Woverflow warnings, missing detail + { dg-do compile } + { dg-options "-Wconversion -Woverflow -Wno-override-init -std=c99" } + { dg-require-effective-target int32plus } */ + +#include + +struct Types +{ + signed char sc; + unsigned char uc; + signed short ss; + unsigned short us; + signed int si; + unsigned int ui; + signed long sl; + unsigned long ul; + signed long long sll; + unsigned long long ull; +}; + +const struct Types t1 = { + /* According to 6.3.1.3 of C11: + -2- Otherwise, if the new type is unsigned, the value is converted + by repeatedly adding or subtracting one more than the maximum + value that can be represented in the new type until the value + is in the range of the new type. + + These conversions are diagnosed by -Wsign-conversion and -Wconversion, + respectively, by mentioning "unsigned conversion" if the conversion + results in sign change, and just "conversion" otherwise, as follows: */ + + .uc = SCHAR_MIN, /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value from .-128. to .128." } */ + .uc = -1, /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value from .-1. to .255." } */ + + .uc = UCHAR_MAX + 1, /* { dg-warning "conversion from 'int' to 'unsigned char' changes value from .256. to .0." } */ + .uc = UCHAR_MAX * 2, /* { dg-warning "conversion from 'int' to 'unsigned char' changes value from .510. to .254." } */ + + /* According to 6.3.1.3 of C11: + -3- Otherwise, the new type is signed and the value cannot be + represented in it; either the result is implementation-defined + or an implementation-defined signal is raised. + + In GCC such conversions wrap and are diagnosed by mentioning "overflow" + if the absolute value of the operand is in excess of the maximum of + the destination of type, and "conversion" otherwise, as follows: */ + + .sc = SCHAR_MAX + 1, /* { dg-warning "conversion from .int. to .signed char. changes value from .128. to .-128." } */ + .sc = SCHAR_MAX + 2, /* { dg-warning "conversion from .int. to .signed char. changes value from .129. to .-127." } */ + .sc = SCHAR_MAX * 2, /* { dg-warning "conversion from .int. to .signed char. changes value from .254. to .-2." } */ + .sc = SCHAR_MAX * 2 + 3, /* { dg-warning "conversion from .int. to .signed char. changes value from .257. to .1." } */ + .sc = SCHAR_MAX * 3 + 3, /* { dg-warning "conversion from .int. to .signed char. changes value from .384. to .-128." } */ + + + .ss = SHRT_MAX + 1, /* { dg-warning "conversion from 'int' to 'short int' changes value from .32768. to .-32768." } */ + .us = USHRT_MAX + 1, /* { dg-warning "unsigned conversion from .int. to .short unsigned int. changes value from .65536. to .0." } */ + + .si = INT_MAX + 1LU, /* { dg-warning "signed conversion from 'long unsigned int. to 'int' changes value from .2147483648. to .-2147483648." } */ + .ui = UINT_MAX + 1L, /* { dg-warning "signed conversion from .long int. to .unsigned int. changes value from .4294967296. to .0." } */ + .ui = UINT_MAX + 1LU, /* { dg-warning "conversion from .long unsigned int. to .unsigned int. changes value from .4294967296. to .0." } */ + + .sl = LONG_MAX + 1LU, /* { dg-warning "signed conversion from .long unsigned int. to .long int. changes value from .9223372036854775808. to .-9223372036854775808." } */ + .ul = ULONG_MAX + 1LU /* there should be some warning here */ +}; diff --git a/gcc/testsuite/gcc.dg/pr35635.c b/gcc/testsuite/gcc.dg/pr35635.c index 86612d5283f..b52354f80a6 100644 --- a/gcc/testsuite/gcc.dg/pr35635.c +++ b/gcc/testsuite/gcc.dg/pr35635.c @@ -32,7 +32,7 @@ void func1() /* At least one branch of ? does not fit in the destination, thus warn. */ unsigned_bit.x = bar != 0 ? 2 : 0; /* { dg-warning "conversion" } */ - unsigned_bit.x = bar != 0 ? 0 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + unsigned_bit.x = bar != 0 ? 0 : -1; /* { dg-warning "-Wsign-conversion" } */ } void func2() @@ -62,7 +62,7 @@ void func3() /* At least one branch of ? does not fit in the destination, thus warn. */ uchar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */ - uchar_x = bar != 0 /* { dg-warning "negative integer implicitly converted to unsigned type" } */ + uchar_x = bar != 0 /* { dg-warning "-Wsign-conversion" } */ ? (unsigned char) 1024 : -1; } diff --git a/gcc/testsuite/gcc.dg/pr59940.c b/gcc/testsuite/gcc.dg/pr59940.c index 6dba8c713fc..cec8d07edd5 100644 --- a/gcc/testsuite/gcc.dg/pr59940.c +++ b/gcc/testsuite/gcc.dg/pr59940.c @@ -9,13 +9,13 @@ int g (void) { sitype si = 12; - unsigned int ui = -1; /* { dg-warning "21:negative integer implicitly converted to unsigned type" } */ + unsigned int ui = -1; /* { dg-warning "21:-Wsign-conversion" } */ unsigned char uc; ui = si; /* { dg-warning "8:conversion" } */ - si = 0x80000000; /* { dg-warning "8:conversion of unsigned constant value to negative integer" } */ + si = 0x80000000; /* { dg-warning "8:-Wsign-conversion" } */ si = 3.2f; /* { dg-warning "8:conversion" } */ - uc = 256; /* { dg-warning "8:large integer implicitly truncated to unsigned type" } */ - si = 0x800000000; /* { dg-warning "8:overflow in implicit constant conversion" } */ + uc = 256; /* { dg-warning "8:-Woverflow" } */ + si = 0x800000000; /* { dg-warning "8:-Woverflow" } */ return f (si) /* { dg-warning "13:conversion" } */ + f (si); /* { dg-warning "15:conversion" } */ } diff --git a/gcc/testsuite/gcc.dg/pr59963-2.c b/gcc/testsuite/gcc.dg/pr59963-2.c index 8eb1a796bbc..1c79397317e 100644 --- a/gcc/testsuite/gcc.dg/pr59963-2.c +++ b/gcc/testsuite/gcc.dg/pr59963-2.c @@ -1,7 +1,6 @@ /* PR c/59963 */ /* { dg-do compile } */ /* { dg-options "-Woverflow -Wconversion" } */ -/* { dg-require-effective-target int32plus } */ extern void bar (unsigned char); extern void bar8 (unsigned char, unsigned char, unsigned char, unsigned char, @@ -13,25 +12,25 @@ extern int f (short a, short b); int g (void) { - return f (0xffffffffL, /* { dg-warning "13:overflow in implicit constant conversion" } */ - 0xffffffffL) /* { dg-warning "13:overflow in implicit constant conversion" } */ - && f (0xffffffffL, /* { dg-warning "9:overflow in implicit constant conversion" } */ - 0xffffffffL); /* { dg-warning "9:overflow in implicit constant conversion" } */ + return f (0xffffffffL, /* { dg-warning "13:-Woverflow" } */ + 0xffffffffL) /* { dg-warning "13:-Woverflow" } */ + && f (0xffffffffL, /* { dg-warning "9:-Woverflow" } */ + 0xffffffffL); /* { dg-warning "9:-Woverflow" } */ } void foo (int i) { - bar (256); /* { dg-warning "8:large integer implicitly truncated to unsigned type" } */ + bar (256); /* { dg-warning "8:-Woverflow" } */ bar (6.66f); /* { dg-warning "8:conversion" } */ - bar8 (-1, /* { dg-warning "9:negative integer implicitly converted to unsigned type" } */ - -2, /* { dg-warning "3:negative integer implicitly converted to unsigned type" } */ - -3, /* { dg-warning "4:negative integer implicitly converted to unsigned type" } */ - -4, /* { dg-warning "5:negative integer implicitly converted to unsigned type" } */ - -5, /* { dg-warning "6:negative integer implicitly converted to unsigned type" } */ - -6, /* { dg-warning "7:negative integer implicitly converted to unsigned type" } */ - -7, /* { dg-warning "8:negative integer implicitly converted to unsigned type" } */ - -8); /* { dg-warning "9:negative integer implicitly converted to unsigned type" } */ + bar8 (-1, /* { dg-warning "9:-Wsign-conversion" } */ + -2, /* { dg-warning "3:-Wsign-conversion" } */ + -3, /* { dg-warning "4:-Wsign-conversion" } */ + -4, /* { dg-warning "5:-Wsign-conversion" } */ + -5, /* { dg-warning "6:-Wsign-conversion" } */ + -6, /* { dg-warning "7:-Wsign-conversion" } */ + -7, /* { dg-warning "8:-Wsign-conversion" } */ + -8); /* { dg-warning "9:-Wsign-conversion" } */ bazu (i, i); /* { dg-warning "9:conversion" } */ - bazi (0x8, 0x80000000); /* { dg-warning "14:conversion of unsigned constant value to negative integer" "" { xfail int16 } } */ + bazi (0x8, 0x80000000); /* { dg-warning "14:-Wsign-conversion" "" { xfail int16 } } */ } diff --git a/gcc/testsuite/gcc.dg/pr60114.c b/gcc/testsuite/gcc.dg/pr60114.c index a2db9c9480c..0ddbe58a277 100644 --- a/gcc/testsuite/gcc.dg/pr60114.c +++ b/gcc/testsuite/gcc.dg/pr60114.c @@ -5,28 +5,28 @@ struct S { int n, u[2]; }; const signed char z[] = { - [0] = 0x100, /* { dg-warning "9:overflow in implicit constant conversion" } */ - [2] = 0x101, /* { dg-warning "9:overflow in implicit constant conversion" } */ + [0] = 0x100, /* { dg-warning "9:-Woverflow" } */ + [2] = 0x101, /* { dg-warning "9:-Woverflow" } */ }; int A[] = { - 0, 0x80000000, /* { dg-warning "16:conversion of unsigned constant value to negative integer" } */ - 0xA, 0x80000000, /* { dg-warning "18:conversion of unsigned constant value to negative integer" } */ - 0xA, 0xA, 0x80000000 /* { dg-warning "23:conversion of unsigned constant value to negative integer" } */ + 0, 0x80000000, /* { dg-warning "16:-Wsign-conversion" } */ + 0xA, 0x80000000, /* { dg-warning "18:-Wsign-conversion" } */ + 0xA, 0xA, 0x80000000 /* { dg-warning "23:-Wsign-conversion" } */ }; -int *p = (int []) { 0x80000000 }; /* { dg-warning "21:conversion of unsigned constant value to negative integer" } */ -union { int k; } u = { .k = 0x80000000 }; /* { dg-warning "29:conversion of unsigned constant value to negative integer" } */ +int *p = (int []) { 0x80000000 }; /* { dg-warning "21:-Wsign-conversion" } */ +union { int k; } u = { .k = 0x80000000 }; /* { dg-warning "29:-Wsign-conversion" } */ typedef int H[]; void foo (void) { - signed char a[][3] = { { 0x100, /* { dg-warning "28:overflow in implicit constant conversion" } */ - 1, 0x100 }, /* { dg-warning "24:overflow in implicit constant conversion" } */ - { '\0', 0x100, '\0' } /* { dg-warning "27:overflow in implicit constant conversion" } */ + signed char a[][3] = { { 0x100, /* { dg-warning "28:-Woverflow" } */ + 1, 0x100 }, /* { dg-warning "24:-Woverflow" } */ + { '\0', 0x100, '\0' } /* { dg-warning "27:-Woverflow" } */ }; - (const signed char []) { 0x100 }; /* { dg-warning "28:overflow in implicit constant conversion" } */ + (const signed char []) { 0x100 }; /* { dg-warning "28:-Woverflow" } */ (const float []) { 1e0, 1e1, 1e100 }; /* { dg-warning "32:conversion" } */ - struct S s1 = { 0x80000000 }; /* { dg-warning "19:conversion of unsigned constant value to negative integer" } */ - struct S s2 = { .n = 0x80000000 }; /* { dg-warning "24:conversion of unsigned constant value to negative integer" } */ - struct S s3 = { .u[1] = 0x80000000 }; /* { dg-warning "27:conversion of unsigned constant value to negative integer" } */ - H h = { 1, 2, 0x80000000 }; /* { dg-warning "17:conversion of unsigned constant value to negative integer" } */ + struct S s1 = { 0x80000000 }; /* { dg-warning "19:-Wsign-conversion" } */ + struct S s2 = { .n = 0x80000000 }; /* { dg-warning "24:-Wsign-conversion" } */ + struct S s3 = { .u[1] = 0x80000000 }; /* { dg-warning "27:-Wsign-conversion" } */ + H h = { 1, 2, 0x80000000 }; /* { dg-warning "17:-Wsign-conversion" } */ } diff --git a/gcc/testsuite/gcc.dg/switch-warn-2.c b/gcc/testsuite/gcc.dg/switch-warn-2.c index 7778b66e087..76fd982b575 100644 --- a/gcc/testsuite/gcc.dg/switch-warn-2.c +++ b/gcc/testsuite/gcc.dg/switch-warn-2.c @@ -10,7 +10,7 @@ foo (unsigned int i) { switch (i) { - case 123456123456ULL: /* { dg-warning "large integer implicitly truncated to unsigned type" } */ + case 123456123456ULL: /* { dg-warning "conversion from .long long unsigned int. to .unsigned int. changes value" } */ return 0; default: return 3; diff --git a/gcc/testsuite/gcc.dg/utf-cvt.c b/gcc/testsuite/gcc.dg/utf-cvt.c index d6f18eeade7..d9927824e3c 100644 --- a/gcc/testsuite/gcc.dg/utf-cvt.c +++ b/gcc/testsuite/gcc.dg/utf-cvt.c @@ -25,9 +25,9 @@ extern void full (unsigned long long); void m (char16_t c0, char32_t c1) { - f_c (c0); /* { dg-warning "alter its value" } */ - fsc (c0); /* { dg-warning "alter its value" } */ - fuc (c0); /* { dg-warning "alter its value" } */ + f_c (c0); /* { dg-warning "conversion from .char16_t\[^\n\r\]*. to .char. may change value" } */ + fsc (c0); /* { dg-warning "may change value" } */ + fuc (c0); /* { dg-warning "may change value" } */ f_s (c0); /* { dg-warning "change the sign" } */ fss (c0); /* { dg-warning "change the sign" } */ fus (c0); @@ -41,12 +41,12 @@ void m (char16_t c0, char32_t c1) fsll (c0); full (c0); - f_c (c1); /* { dg-warning "alter its value" } */ - fsc (c1); /* { dg-warning "alter its value" } */ - fuc (c1); /* { dg-warning "alter its value" } */ - f_s (c1); /* { dg-warning "alter its value" } */ - fss (c1); /* { dg-warning "alter its value" } */ - fus (c1); /* { dg-warning "alter its value" } */ + f_c (c1); /* { dg-warning "may change value" } */ + fsc (c1); /* { dg-warning "may change value" } */ + fuc (c1); /* { dg-warning "may change value" } */ + f_s (c1); /* { dg-warning "may change value" } */ + fss (c1); /* { dg-warning "may change value" } */ + fus (c1); /* { dg-warning "may change value" } */ f_i (c1); /* { dg-warning "change the sign" "" { target { ! int16 } } } */ fsi (c1); /* { dg-warning "change the sign" "" { target { ! int16 } } } */ fui (c1); diff --git a/gcc/testsuite/gcc.dg/utf16-4.c b/gcc/testsuite/gcc.dg/utf16-4.c index 6ef4ae3ff7e..f9ebd61845a 100644 --- a/gcc/testsuite/gcc.dg/utf16-4.c +++ b/gcc/testsuite/gcc.dg/utf16-4.c @@ -12,10 +12,10 @@ char16_t c2 = u'\U00064321'; /* { dg-warning "constant too long" } */ char16_t c3 = 'a'; char16_t c4 = U'a'; char16_t c5 = U'\u2029'; -char16_t c6 = U'\U00064321'; /* { dg-warning "implicitly truncated" } */ +char16_t c6 = U'\U00064321'; /* { dg-warning "conversion from .unsigned int. to .char16_t {aka short unsigned int}. changes value from .410401. to .17185." } */ char16_t c7 = L'a'; char16_t c8 = L'\u2029'; -char16_t c9 = L'\U00064321'; /* { dg-warning "implicitly truncated" "" { target { 4byte_wchar_t } } } */ +char16_t c9 = L'\U00064321'; /* { dg-warning "conversion" "" { target { 4byte_wchar_t } } } */ /* { dg-warning "constant too long" "" { target { ! 4byte_wchar_t } } .-1 } */ int main () {}