From: Martin Sebor Date: Sat, 3 Jun 2017 02:49:30 +0000 (+0000) Subject: PR c/80892 - -Wfloat-conversion now warns about non-floats X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2474f48f738cbbdce18f4ded7afd7e57d8b1dcc4;p=gcc.git 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. From-SVN: r248852 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 0d54c903d6e..569b456a724 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2017-06-02 Martin Sebor + + PR c/80892 + * c-warn.c (conversion_warning): Use -Wconversion for integer + conversion and -Wfloat-conversion for floating one. + 2017-06-02 Bernd Edlinger * c.opt (Wsizeof-pointer-div): New warning option. diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 012675bf6e9..35321a6cb1b 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/ChangeLog b/gcc/testsuite/ChangeLog index d150f8686ee..537e6422d22 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-02 Martin Sebor + + PR c/80892 + * c-c++-common/Wfloat-conversion-2.c: New test. + 2017-06-02 Paolo Carlini PR c++/68754