]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/60087 (Incorrect column number for -Wsign-compare)
authorMarek Polacek <polacek@redhat.com>
Thu, 6 Feb 2014 13:57:37 +0000 (13:57 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 6 Feb 2014 13:57:37 +0000 (13:57 +0000)
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
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr60087.c [new file with mode: 0644]

index 38fc2d23e34229dafeba4be8646d3f85ad974dca..1e61bc341a7c36f65adf70810ccf91bbc8a4ce31 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c/60087
+       * c-common.c (warn_for_sign_compare): Call warning_at with location
+       instead of warning.
+
 2014-02-05  Marek Polacek  <polacek@redhat.com>
 
        PR c/53123
index 007e7275fc8650e4510fff53dbccda28efab6133..50cc848fe902502118ed9ee1d46b9e00f23e720a 100644 (file)
@@ -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");
index 43883cea6751c912ae40ea4386ba94e26aa66cc6..ef4a72e68b2ffa06f5d43f470541ce7c70b9ae18 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c/60087
+       * gcc.dg/pr60087.c: New test.
+
 2014-02-06  Alan Modra  <amodra@gmail.com>
 
        * 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 (file)
index 0000000..9cdd589
--- /dev/null
@@ -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" } */
+}