re PR c/60351 (Incorrect column number for warning on "right shift count is negative")
authorMarek Polacek <polacek@redhat.com>
Wed, 30 Apr 2014 06:08:17 +0000 (06:08 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 30 Apr 2014 06:08:17 +0000 (06:08 +0000)
PR c/60351
* c-typeck.c (build_binary_op): Use location when warning about
shift count.

* gcc.dg/pr60351.c: New test.

From-SVN: r209925

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr60351.c [new file with mode: 0644]

index 80841af40ee89cffa02d0ca5eccb2d4aba253ed5..ee7c9bef05d0f3b6fac4fd44c33a6c6181707662 100644 (file)
@@ -1,3 +1,9 @@
+2014-04-30  Marek Polacek  <polacek@redhat.com>
+
+       PR c/60351
+       * c-typeck.c (build_binary_op): Use location when warning about
+       shift count.
+
 2014-04-25  Marek Polacek  <polacek@redhat.com>
 
        PR c/18079
index 62c72dfdd70884d29d5a330ab3765a4121e551a4..e23c6dbbb0efadbf8d310071a3c15676af76dc2a 100644 (file)
@@ -10402,7 +10402,7 @@ build_binary_op (location_t location, enum tree_code code,
                {
                  int_const = false;
                  if (c_inhibit_evaluation_warnings == 0)
-                   warning (0, "right shift count is negative");
+                   warning_at (location, 0, "right shift count is negative");
                }
              else
                {
@@ -10413,7 +10413,8 @@ build_binary_op (location_t location, enum tree_code code,
                    {
                      int_const = false;
                      if (c_inhibit_evaluation_warnings == 0)
-                       warning (0, "right shift count >= width of type");
+                       warning_at (location, 0, "right shift count >= width "
+                                   "of type");
                    }
                }
            }
@@ -10455,14 +10456,15 @@ build_binary_op (location_t location, enum tree_code code,
                {
                  int_const = false;
                  if (c_inhibit_evaluation_warnings == 0)
-                   warning (0, "left shift count is negative");
+                   warning_at (location, 0, "left shift count is negative");
                }
 
              else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
                {
                  int_const = false;
                  if (c_inhibit_evaluation_warnings == 0)
-                   warning (0, "left shift count >= width of type");
+                   warning_at (location, 0, "left shift count >= width of "
+                               "type");
                }
            }
 
index 014835619023b59d3e43d8c9990ef38be3346777..79238530e15e11c6e7c4690cd7576ce08ad308b2 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-30  Marek Polacek  <polacek@redhat.com>
+
+       PR c/60351
+       * gcc.dg/pr60351.c: New test.
+
 2013-04-29  Alan Lawrence  <alan.lawrence@arm.com>
 
        * gcc.target/arm/simd/simd.exp: New file.
diff --git a/gcc/testsuite/gcc.dg/pr60351.c b/gcc/testsuite/gcc.dg/pr60351.c
new file mode 100644 (file)
index 0000000..29184d9
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c/60351 */
+/* { dg-do compile } */
+
+void
+f (int i)
+{
+  i >> -1; /* { dg-warning "5:right shift count is negative" } */
+  i >> 250; /* { dg-warning "5:right shift count >= width of type" } */
+  i << -1; /* { dg-warning "5:left shift count is negative" } */
+  i << 250; /* { dg-warning "5:left shift count >= width of type" } */
+}