On 25 May 2017 at 00:16, Martin Sebor <mse...@gmail.com> wrote: > On 05/24/2017 11:08 AM, Joseph Myers wrote: >> >> On Wed, 17 May 2017, Martin Sebor wrote: >> >>> @@ -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) >>> + ? "conversion from %qT to %qT " >>> + "changes value from %qE to %qE" >>> + : "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) >>> + ? "conversion from %qT to %qT " >>> + "changes the value of %qE" >>> + : "unsigned conversion from %qT to %qT " >>> + "changes the value of %qE"), >>> + exprtype, type, expr); >>> + } >> >> >> You need to use G_() around both arguments to ?:, otherwise only one will >> get extracted for translation. >> >>> diff --git a/gcc/testsuite/c-c++-common/pr68657-1.c >>> b/gcc/testsuite/c-c++-common/pr68657-1.c >>> index 84f3e54..33fdf86 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 .4294967291." } */ >> >> >> The more specific match would fail for targets with 16-bit int. You need >> to keep it less specific in this test (if you want to test the more >> specific text as well, another test could be added for that, restricted to >> the int32 effective-target). >> >> (The changes to Wconversion-real-integer-3.C and >> Wconversion-real-integer2.C are OK in that those tests are restricted to >> int32plus, although in theory 64-bit int would be an issue there.) >> >>> + /* 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 conversios wrap and diagnosed by mentioning "overflow" >>> + if the absolut value of the operand is in excess of the maximum of >>> + the destination of type, and "conversion" otherwise, as follows: >>> */ >> >> >> s/conversios/conversions/; s/absolut/absolute/ >> >> OK with those changes. > > > Thanks for the careful review! Done and committed in r248431. >
Hi, I have noticed failures on arm*: Executed from: gcc.dg/fixed-point/fixed-point.exp gcc.dg/fixed-point/int-warning.c (test for warnings, line 12) gcc.dg/fixed-point/int-warning.c (test for warnings, line 13) gcc.dg/fixed-point/int-warning.c (test for warnings, line 14) gcc.dg/fixed-point/int-warning.c (test for warnings, line 15) gcc.dg/fixed-point/int-warning.c (test for warnings, line 16) gcc.dg/fixed-point/int-warning.c (test for warnings, line 17) gcc.dg/fixed-point/int-warning.c (test for warnings, line 18) gcc.dg/fixed-point/int-warning.c (test for warnings, line 19) gcc.dg/fixed-point/int-warning.c (test for warnings, line 20) gcc.dg/fixed-point/int-warning.c (test for warnings, line 21) gcc.dg/fixed-point/int-warning.c (test for warnings, line 22) gcc.dg/fixed-point/int-warning.c (test for warnings, line 23) gcc.dg/fixed-point/int-warning.c (test for excess errors) Excess errors: /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:12:8: warning: overflow in conversion from '_Accum' to 'signed char' chages value from '5.0e+2' to '-12' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:13:8: warning: overflow in conversion from '_Accum' to 'signed char' chages value from '-5.0e+2' to '12' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:14:8: warning: overflow in conversion from 'long _Accum' to 'signed char' chages value from '5.0e+2' to '-12' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:15:8: warning: overflow in conversion from 'long _Accum' to 'signed char' chages value from '-5.0e+2' to '12' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:16:8: warning: overflow in conversion from 'long long _Accum' to 'signed char' chages value from '5.0e+2' to '-12' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:17:8: warning: overflow in conversion from 'long long _Accum' to 'signed char' chages value from '-5.0e+2' to '12' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:18:8: warning: overflow in conversion from '_Accum' to 'unsigned char' chages value from '5.0e+2' to '244' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:19:8: warning: overflow in conversion from '_Accum' to 'unsigned char' chages value from '-5.0e+2' to '12' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:20:8: warning: overflow in conversion from 'long _Accum' to 'unsigned char' chages value from '5.0e+2' to '244' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:21:8: warning: overflow in conversion from 'long _Accum' to 'unsigned char' chages value from '-5.0e+2' to '12' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:22:8: warning: overflow in conversion from 'long long _Accum' to 'unsigned char' chages value from '5.0e+2' to '244' [-Woverflow] /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/fixed-point/int-warning.c:23:8: warning: overflow in conversion from 'long long _Accum' to 'unsigned char' chages value from '-5.0e+2' to '12' [-Woverflow] Still present at r248552. Thanks, Christophe > Martin >