aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-04-24 11:53:27 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-04-24 11:53:27 +0000
commit4853031ec832b9fd29e0894016038cc9f83e31cc (patch)
tree722f8443b2e54bb8e8d1e525c5679186842f8208
parentb878781346e97ade9087d5c010e29ff09492b6fb (diff)
downloadgcc-4853031ec832b9fd29e0894016038cc9f83e31cc.zip
gcc-4853031ec832b9fd29e0894016038cc9f83e31cc.tar.gz
gcc-4853031ec832b9fd29e0894016038cc9f83e31cc.tar.bz2
re PR c/65830 (-Wno-shift-count-negative -Wno-shift-count-overflow don't work with const ints)
PR c/65830 * c-common.c (c_fully_fold_internal): Use OPT_Wshift_count_negative and OPT_Wshift_count_overflow. * c-c++-common/pr65830.c: New test. From-SVN: r222407
-rw-r--r--gcc/c-family/ChangeLog6
-rw-r--r--gcc/c-family/c-common.c14
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/pr65830.c16
4 files changed, 35 insertions, 6 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 270ef70..718aa2a 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,5 +1,11 @@
2015-04-24 Marek Polacek <polacek@redhat.com>
+ PR c/65830
+ * c-common.c (c_fully_fold_internal): Use OPT_Wshift_count_negative
+ and OPT_Wshift_count_overflow.
+
+2015-04-24 Marek Polacek <polacek@redhat.com>
+
PR c/61534
* c-common.c (warn_logical_operator): Bail if either operand comes
from a macro expansion.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index b09bbb8..b8e141e 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -1370,15 +1370,17 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
&& c_inhibit_evaluation_warnings == 0)
{
if (tree_int_cst_sgn (op1) < 0)
- warning_at (loc, 0, (code == LSHIFT_EXPR
- ? G_("left shift count is negative")
- : G_("right shift count is negative")));
+ warning_at (loc, OPT_Wshift_count_negative,
+ (code == LSHIFT_EXPR
+ ? G_("left shift count is negative")
+ : G_("right shift count is negative")));
else if (compare_tree_int (op1,
TYPE_PRECISION (TREE_TYPE (orig_op0)))
>= 0)
- warning_at (loc, 0, (code == LSHIFT_EXPR
- ? G_("left shift count >= width of type")
- : G_("right shift count >= width of type")));
+ warning_at (loc, OPT_Wshift_count_overflow,
+ (code == LSHIFT_EXPR
+ ? G_("left shift count >= width of type")
+ : G_("right shift count >= width of type")));
}
if ((code == TRUNC_DIV_EXPR
|| code == CEIL_DIV_EXPR
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c493bd8..936a164 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2015-04-24 Marek Polacek <polacek@redhat.com>
+ PR c/65830
+ * c-c++-common/pr65830.c: New test.
+
+2015-04-24 Marek Polacek <polacek@redhat.com>
+
PR c/61534
* c-c++-common/pr61534-1.c: New test.
diff --git a/gcc/testsuite/c-c++-common/pr65830.c b/gcc/testsuite/c-c++-common/pr65830.c
new file mode 100644
index 0000000..e115f18
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr65830.c
@@ -0,0 +1,16 @@
+/* PR c/65830 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wno-shift-count-negative -Wno-shift-count-overflow" } */
+
+int
+foo (int x)
+{
+ const int a = sizeof (int) * __CHAR_BIT__;
+ const int b = -7;
+ int c = 0;
+ c += x << a; /* { dg-bogus "left shift count >= width of type" } */
+ c += x << b; /* { dg-bogus "left shift count is negative" } */
+ c += x >> a; /* { dg-bogus "right shift count >= width of type" } */
+ c += x >> b; /* { dg-bogus "right shift count is negative" } */
+ return c;
+}