* [PATCH] use the right conversion warning option (PR c/80892)
@ 2017-05-30 19:54 Martin Sebor
2017-06-02 0:38 ` Eric Gallager
0 siblings, 1 reply; 4+ messages in thread
From: Martin Sebor @ 2017-05-30 19:54 UTC (permalink / raw)
To: Gcc Patch List, Joseph Myers
[-- Attachment #1: Type: text/plain, Size: 189 bytes --]
The conversion enhancements I committed in r248431 introduced
an unintended change in which warning option is used to issue
certain integer conversion warnings. Attached is a fix.
Martin
[-- Attachment #2: gcc-80892.diff --]
[-- Type: text/x-patch, Size: 1897 bytes --]
PR c/80892 - -Wfloat-conversion now warns about non-floats
gcc/c-family/ChangeLog:
PR c/80892
* c-warn.c (conversion_warning): Use -Wconversion for integer
conversion and -Wfloat-conversion for floating one.
gcc/testsuite/ChangeLog:
PR c/80892
* c-c++-common/Wfloat-conversion-2.c: New test.
diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index 012675b..35321a6 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -1043,10 +1043,19 @@ conversion_warning (location_t loc, tree type, tree expr, tree result)
"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);
+ else
+ {
+ int warnopt;
+ if (conversion_kind == UNSAFE_REAL)
+ warnopt = OPT_Wfloat_conversion;
+ else if (conversion_kind)
+ warnopt = OPT_Wconversion;
+ else
+ break;
+ warning_at (loc, warnopt,
+ "conversion from %qT to %qT may change value",
+ expr_type, type);
+ }
}
}
diff --git a/gcc/testsuite/c-c++-common/Wfloat-conversion-2.c b/gcc/testsuite/c-c++-common/Wfloat-conversion-2.c
new file mode 100644
index 0000000..626e35b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wfloat-conversion-2.c
@@ -0,0 +1,19 @@
+/* PR c/80892 - [8 regression] -Wfloat-conversion now warns about non-floats
+ { dg-do compile }
+ { dg-options "-Wconversion -Wfloat-conversion" }
+ { dg-require-effective-target int32plus }
+ { dg-require-effective-target double64plus } */
+
+void fschar (char);
+
+void fulong (unsigned long x)
+{
+ fschar (x); /* { dg-warning "\\[-Wconversion\\]" } */
+}
+
+void ffloat (float);
+
+void fdouble (double x)
+{
+ ffloat (x); /* { dg-warning "\\[-Wfloat-conversion\\]" } */
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] use the right conversion warning option (PR c/80892)
2017-05-30 19:54 [PATCH] use the right conversion warning option (PR c/80892) Martin Sebor
@ 2017-06-02 0:38 ` Eric Gallager
2017-06-02 14:33 ` Martin Sebor
0 siblings, 1 reply; 4+ messages in thread
From: Eric Gallager @ 2017-06-02 0:38 UTC (permalink / raw)
To: Martin Sebor; +Cc: Gcc Patch List, Joseph Myers
I tested this patch; it fixes the warnings that caused me to open the
bug in the first place. Thank you!
Eric
On 5/30/17, Martin Sebor <msebor@gmail.com> wrote:
> The conversion enhancements I committed in r248431 introduced
> an unintended change in which warning option is used to issue
> certain integer conversion warnings. Attached is a fix.
>
> Martin
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] use the right conversion warning option (PR c/80892)
2017-06-02 0:38 ` Eric Gallager
@ 2017-06-02 14:33 ` Martin Sebor
2017-06-03 2:51 ` [committed] " Martin Sebor
0 siblings, 1 reply; 4+ messages in thread
From: Martin Sebor @ 2017-06-02 14:33 UTC (permalink / raw)
To: Eric Gallager; +Cc: Gcc Patch List, Joseph Myers
On 06/01/2017 06:38 PM, Eric Gallager wrote:
> I tested this patch; it fixes the warnings that caused me to open the
> bug in the first place. Thank you!
Thanks for validating it. I'll go ahead and commit the fix
as obvious if there are no objections in the next few hours.
Martin
>
> Eric
>
>
> On 5/30/17, Martin Sebor <msebor@gmail.com> wrote:
>> The conversion enhancements I committed in r248431 introduced
>> an unintended change in which warning option is used to issue
>> certain integer conversion warnings. Attached is a fix.
>>
>> Martin
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [committed] use the right conversion warning option (PR c/80892)
2017-06-02 14:33 ` Martin Sebor
@ 2017-06-03 2:51 ` Martin Sebor
0 siblings, 0 replies; 4+ messages in thread
From: Martin Sebor @ 2017-06-03 2:51 UTC (permalink / raw)
To: Gcc Patch List; +Cc: Eric Gallager, Joseph Myers
I have committed the patch in r248852.
Martin
On 06/02/2017 08:33 AM, Martin Sebor wrote:
> On 06/01/2017 06:38 PM, Eric Gallager wrote:
>> I tested this patch; it fixes the warnings that caused me to open the
>> bug in the first place. Thank you!
>
> Thanks for validating it. I'll go ahead and commit the fix
> as obvious if there are no objections in the next few hours.
>
> Martin
>
>>
>> Eric
>>
>>
>> On 5/30/17, Martin Sebor <msebor@gmail.com> wrote:
>>> The conversion enhancements I committed in r248431 introduced
>>> an unintended change in which warning option is used to issue
>>> certain integer conversion warnings. Attached is a fix.
>>>
>>> Martin
>>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-03 2:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 19:54 [PATCH] use the right conversion warning option (PR c/80892) Martin Sebor
2017-06-02 0:38 ` Eric Gallager
2017-06-02 14:33 ` Martin Sebor
2017-06-03 2:51 ` [committed] " Martin Sebor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).