From 0a756a3ffc875e13842708c8affcce48c9644dc7 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 6 Feb 2014 13:57:37 +0000 Subject: [PATCH] re PR c/60087 (Incorrect column number for -Wsign-compare) PR c/60087 c-family/ * c-common.c (warn_for_sign_compare): Call warning_at with location instead of warning. testsuite/ * gcc.dg/pr60087.c: New test. From-SVN: r207554 --- gcc/c-family/ChangeLog | 6 ++++++ gcc/c-family/c-common.c | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr60087.c | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr60087.c diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 38fc2d23e342..1e61bc341a7c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2014-02-06 Marek Polacek + + PR c/60087 + * c-common.c (warn_for_sign_compare): Call warning_at with location + instead of warning. + 2014-02-05 Marek Polacek PR c/53123 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 007e7275fc86..50cc848fe902 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -11285,8 +11285,8 @@ warn_for_sign_compare (location_t location, if ((mask & constant) != mask) { if (constant == 0) - warning (OPT_Wsign_compare, - "promoted ~unsigned is always non-zero"); + warning_at (location, OPT_Wsign_compare, + "promoted ~unsigned is always non-zero"); else warning_at (location, OPT_Wsign_compare, "comparison of promoted ~unsigned with constant"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 43883cea6751..ef4a72e68b2f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-02-06 Marek Polacek + + PR c/60087 + * gcc.dg/pr60087.c: New test. + 2014-02-06 Alan Modra * gcc.target/powerpc/pr60032.c: New. diff --git a/gcc/testsuite/gcc.dg/pr60087.c b/gcc/testsuite/gcc.dg/pr60087.c new file mode 100644 index 000000000000..9cdd5897354e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr60087.c @@ -0,0 +1,14 @@ +/* PR c/60087 */ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +void +foo (unsigned int ui, int i) +{ + const unsigned char uc = 0; + _Bool b; + b = 0 != ~uc; /* { dg-warning "9:promoted ~unsigned is always non-zero" } */ + b = 2 != ~uc; /* { dg-warning "9:comparison of promoted ~unsigned with constant" } */ + b = uc == ~uc; /* { dg-warning "10:comparison of promoted ~unsigned with unsigned" } */ + b = i == ui; /* { dg-warning "9:comparison between signed and unsigned integer expressions" } */ +} -- 2.47.3