From 200dd99c9b7ceec0bbae10b16ce1ffc9ffe073f9 Mon Sep 17 00:00:00 2001 From: manu Date: Fri, 11 Jun 2010 19:56:18 +0000 Subject: [PATCH] =?utf8?q?2010-06-11=20=20Manuel=20L=C3=B3pez-Ib=C3=A1?= =?utf8?q?=C3=B1ez=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit c-family/ * c-common.c (conversion_warning): Warn at expression location. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160631 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c-common.c | 32 +++++++++++++++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index bd9c0f5..785ae95 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2010-06-11 Manuel López-Ibáñez + + * c-common.c (conversion_warning): Warn at expression + location. + 2010-06-10 Joseph Myers * c-opts.c (c_common_handle_option): Don't handle diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 7c841b1..f1dfe71 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1838,6 +1838,8 @@ conversion_warning (tree type, tree expr) int i; const int expr_num_operands = TREE_OPERAND_LENGTH (expr); tree expr_type = TREE_TYPE (expr); + location_t loc = EXPR_HAS_LOCATION (expr) + ? EXPR_LOCATION (expr) : input_location; if (!warn_conversion && !warn_sign_conversion) return; @@ -1869,8 +1871,8 @@ conversion_warning (tree type, tree expr) can hold the values 0 and -1) doesn't lose information - but it does change the value. */ if (TYPE_PRECISION (type) == 1 && !TYPE_UNSIGNED (type)) - warning (OPT_Wconversion, - "conversion to %qT from boolean expression", type); + warning_at (loc, OPT_Wconversion, + "conversion to %qT from boolean expression", type); return; case REAL_CST: @@ -1891,11 +1893,11 @@ conversion_warning (tree type, tree expr) { if (TYPE_UNSIGNED (type) && !TYPE_UNSIGNED (expr_type) && tree_int_cst_sgn (expr) < 0) - warning (OPT_Wsign_conversion, - "negative integer implicitly converted to unsigned type"); + warning_at (loc, OPT_Wsign_conversion, "negative integer" + " implicitly converted to unsigned type"); else if (!TYPE_UNSIGNED (type) && TYPE_UNSIGNED (expr_type)) - warning (OPT_Wsign_conversion, "conversion of unsigned constant " - "value to negative integer"); + warning_at (loc, OPT_Wsign_conversion, "conversion of unsigned" + " constant value to negative integer"); else give_warning = true; } @@ -1920,9 +1922,9 @@ conversion_warning (tree type, tree expr) } if (give_warning) - warning (OPT_Wconversion, - "conversion to %qT alters %qT constant value", - type, expr_type); + warning_at (loc, OPT_Wconversion, + "conversion to %qT alters %qT constant value", + type, expr_type); return; @@ -2013,9 +2015,9 @@ conversion_warning (tree type, tree expr) unsigned but expr is signed, then negative values will be changed. */ || (TYPE_UNSIGNED (type) && !TYPE_UNSIGNED (expr_type))) - warning (OPT_Wsign_conversion, "conversion to %qT from %qT " - "may change the sign of the result", - type, expr_type); + warning_at (loc, OPT_Wsign_conversion, "conversion to %qT from %qT " + "may change the sign of the result", + type, expr_type); } /* Warn for integer types converted to real types if and only if @@ -2049,9 +2051,9 @@ conversion_warning (tree type, tree expr) if (give_warning) - warning (OPT_Wconversion, - "conversion to %qT from %qT may alter its value", - type, expr_type); + warning_at (loc, OPT_Wconversion, + "conversion to %qT from %qT may alter its value", + type, expr_type); } } -- 2.7.4