diff mbox

add more detail to -Wconversion and -Woverflow (PR 80731)

Message ID 749f66c3-5201-4754-d7a2-acc7248eaa9a@foss.arm.com
State New
Headers show

Commit Message

Thomas Preudhomme June 5, 2017, 4:05 p.m. UTC
Hi,

newlib-stdint.h defines UINT32_TYPE as "long unsigned int" for ILP32
targets. This leads such target to warn on "long unsigned int"
conversation rather than "unsigned int". This patch modifies the
dg-warning regexp to allow an option "long " prefix in the warning,
thereby working for LP64 and ILP32 targets.

ChangeLog entry is as follows:

*** gcc/testsuite/ChangeLog ***

2017-06-05  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* gcc.dg/utf16-4.c: Accept "long unsigned int" as well as
	"unsigned int" in conversation warning on line 15.

Is it ok for trunk?

The dg-warning PASSes once this patch is applied.

Best regards,

Thomas

On 04/06/17 23:54, Martin Sebor wrote:
> On 06/02/2017 11:11 AM, Renlin Li wrote:
>> Hi Martin,
>>
>> I noticed the following failures after your change r248431.
>> FAIL: c-c++-common/Wfloat-conversion.c  -Wc++-compat   (test for
>> warnings, line 42)
>> FAIL: c-c++-common/Wfloat-conversion.c  -Wc++-compat   (test for
>> warnings, line 43)
>>
>> It happens on arm target which is not a large_long_double target.
>> The patch here add the missing target selector. After the change, those
>> test
>> won't checked in arm target.
>>
>> Here I have a simple fix to it. Okay to commit?
>
> r248431 wasn't meant to change when any of these warnings fire,
> only their text and the amount of detail included in them.  The
> removal of the { target large_long_double } selector was by
> accident.
>
> Please go ahead and commit your fix.  Thanks!
>
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2017-06-02 Renlin Li <renlin.li@arm.com>
>>
>> * c-c++-common/Wfloat-conversion.c: Add large_long_double target
>> selector to related line.
>>
>>
>>
>> And there is another failure:
>> FAIL: gcc.dg/utf16-4.c  (test for warnings, line 15)
>>
>> The warning message is slightly different from expected.
>> utf16-4.c:10:15: warning: character constant too long for its type
>> utf16-4.c:15:15: warning: conversion from 'long unsigned int' to
>> 'char16_t {aka short unsigned int}' changes value from '410401' to '17185'
>
> The test passes for me now.  The initial commit had introduced
> bug 80731 but it's recently been fixed.  Can you please try
> again with the latest sources?
>
> Martin

Comments

Martin Sebor June 5, 2017, 4:46 p.m. UTC | #1
On 06/05/2017 10:05 AM, Thomas Preudhomme wrote:
> Hi,
>
> newlib-stdint.h defines UINT32_TYPE as "long unsigned int" for ILP32
> targets. This leads such target to warn on "long unsigned int"
> conversation rather than "unsigned int". This patch modifies the
> dg-warning regexp to allow an option "long " prefix in the warning,
> thereby working for LP64 and ILP32 targets.

Ah, that explains it.

>
> ChangeLog entry is as follows:
>
> *** gcc/testsuite/ChangeLog ***
>
> 2017-06-05  Thomas Preud'homme  <thomas.preudhomme@arm.com>
>
>     * gcc.dg/utf16-4.c: Accept "long unsigned int" as well as
>     "unsigned int" in conversation warning on line 15.
>
> Is it ok for trunk?
>
> The dg-warning PASSes once this patch is applied.

Yes, relaxing the test to allow for both underlying char32_t types
makes sense.

Thanks
Martin

>
> Best regards,
>
> Thomas
>
> On 04/06/17 23:54, Martin Sebor wrote:
>> On 06/02/2017 11:11 AM, Renlin Li wrote:
>>> Hi Martin,
>>>
>>> I noticed the following failures after your change r248431.
>>> FAIL: c-c++-common/Wfloat-conversion.c  -Wc++-compat   (test for
>>> warnings, line 42)
>>> FAIL: c-c++-common/Wfloat-conversion.c  -Wc++-compat   (test for
>>> warnings, line 43)
>>>
>>> It happens on arm target which is not a large_long_double target.
>>> The patch here add the missing target selector. After the change, those
>>> test
>>> won't checked in arm target.
>>>
>>> Here I have a simple fix to it. Okay to commit?
>>
>> r248431 wasn't meant to change when any of these warnings fire,
>> only their text and the amount of detail included in them.  The
>> removal of the { target large_long_double } selector was by
>> accident.
>>
>> Please go ahead and commit your fix.  Thanks!
>>
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>> 2017-06-02 Renlin Li <renlin.li@arm.com>
>>>
>>> * c-c++-common/Wfloat-conversion.c: Add large_long_double target
>>> selector to related line.
>>>
>>>
>>>
>>> And there is another failure:
>>> FAIL: gcc.dg/utf16-4.c  (test for warnings, line 15)
>>>
>>> The warning message is slightly different from expected.
>>> utf16-4.c:10:15: warning: character constant too long for its type
>>> utf16-4.c:15:15: warning: conversion from 'long unsigned int' to
>>> 'char16_t {aka short unsigned int}' changes value from '410401' to
>>> '17185'
>>
>> The test passes for me now.  The initial commit had introduced
>> bug 80731 but it's recently been fixed.  Can you please try
>> again with the latest sources?
>>
>> Martin
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.dg/utf16-4.c b/gcc/testsuite/gcc.dg/utf16-4.c
index f9ebd61845a15fc657a2f906d3f684768993df44..e2f115ebc813ba380718254db699db8ef96e532b 100644
--- a/gcc/testsuite/gcc.dg/utf16-4.c
+++ b/gcc/testsuite/gcc.dg/utf16-4.c
@@ -12,7 +12,7 @@  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 "conversion from .unsigned int. to .char16_t {aka short unsigned int}. changes value from .410401. to .17185." } */
+char16_t	c6 = U'\U00064321';	/* { dg-warning "conversion from .(long )?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 "conversion" "" { target { 4byte_wchar_t } } } */