diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2014-11-10 20:14:41 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2014-11-10 20:14:41 +0000 |
commit | 13c216556de997e8bda737d18a41ebe61bce1d79 (patch) | |
tree | a319274155607b59e6fd0d9bad41edc6a68b2038 /gcc | |
parent | de2b09ec2fac5fbbc0490f2768237f97261361ce (diff) | |
download | gcc-13c216556de997e8bda737d18a41ebe61bce1d79.zip gcc-13c216556de997e8bda737d18a41ebe61bce1d79.tar.gz gcc-13c216556de997e8bda737d18a41ebe61bce1d79.tar.bz2 |
invoke.texi ([-Wshift-count-negative, [...]): Add.
2014-11-10 Paolo Carlini <paolo.carlini@oracle.com>
* doc/invoke.texi ([-Wshift-count-negative, -Wshift-count-overflow]):
Add.
/c-family
2014-11-10 Paolo Carlini <paolo.carlini@oracle.com>
* c.opt ([Wshift-count-negative, Wshift-count-overflow]): Add.
/cp
2014-11-10 Paolo Carlini <paolo.carlini@oracle.com>
* typeck.c (cp_build_binary_op): Use OPT_Wshift_count_negative and
OPT_Wshift_count_overflow in the warnings.
/c
2014-11-10 Paolo Carlini <paolo.carlini@oracle.com>
* c-typeck.c (build_binary_op): Use OPT_Wshift_count_negative and
OPT_Wshift_count_overflow in the warnings.
/testsuite
2014-11-10 Paolo Carlini <paolo.carlini@oracle.com>
* c-c++-common/Wshift-count-overflow-1.c: New.
* c-c++-common/Wshift-count-overflow-2.c: Likewise.
* c-c++-common/Wshift-count-negative-1.c: Likewise.
* c-c++-common/Wshift-count-negative-2.c: Likewise.
From-SVN: r217313
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 14 | ||||
-rw-r--r-- | gcc/c/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 14 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 12 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wshift-count-negative-1.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wshift-count-negative-2.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wshift-count-overflow-1.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wshift-count-overflow-2.c | 8 |
13 files changed, 96 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 95ad903..6432b52 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-11-10 Paolo Carlini <paolo.carlini@oracle.com> + + * doc/invoke.texi ([-Wshift-count-negative, -Wshift-count-overflow]): + Add. + 2014-11-10 Richard Sandiford <richard.sandiford@arm.com> * config/frv/frv.c (frv_io_handle_use_1): Delete. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f2295ed..f0fa714 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2014-11-10 Paolo Carlini <paolo.carlini@oracle.com> + + * c.opt ([Wshift-count-negative, Wshift-count-overflow]): Add. + 2014-11-10 Edward Smith-Rowland <3dw4rd@verizon.net> * c-cppbuiltin.c (__has_attribute, __has_cpp_attribute): New macros; diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 66c62fb..85dcb98 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -760,13 +760,21 @@ Wselector ObjC ObjC++ Var(warn_selector) Warning Warn if a selector has multiple methods +Wsequence-point +C ObjC C++ ObjC++ Var(warn_sequence_point) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) +Warn about possible violations of sequence point rules + Wshadow-ivar ObjC ObjC++ Var(warn_shadow_ivar) EnabledBy(Wshadow) Init(1) Warning Warn if a local declaration hides an instance variable -Wsequence-point -C ObjC C++ ObjC++ Var(warn_sequence_point) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) -Warn about possible violations of sequence point rules +Wshift-count-negative +C ObjC C++ ObjC++ Var(warn_shift_count_negative) Init(1) Warning +Warn if shift count is negative + +Wshift-count-overflow +C ObjC C++ ObjC++ Var(warn_shift_count_overflow) Init(1) Warning +Warn if shift count >= width of type Wsign-compare C ObjC C++ ObjC++ Var(warn_sign_compare) Warning LangEnabledBy(C++ ObjC++,Wall) diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 24781e1..a2b3c78 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2014-11-10 Paolo Carlini <paolo.carlini@oracle.com> + + * c-typeck.c (build_binary_op): Use OPT_Wshift_count_negative and + OPT_Wshift_count_overflow in the warnings. + 2014-10-30 Marek Polacek <polacek@redhat.com> * c-objc-common.c (c_tree_printer) <case 'T'>: For a typedef name, diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 79dbc3d..77ce549 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -10491,7 +10491,8 @@ build_binary_op (location_t location, enum tree_code code, { int_const = false; if (c_inhibit_evaluation_warnings == 0) - warning_at (location, 0, "right shift count is negative"); + warning_at (location, OPT_Wshift_count_negative, + "right shift count is negative"); } else { @@ -10502,8 +10503,8 @@ build_binary_op (location_t location, enum tree_code code, { int_const = false; if (c_inhibit_evaluation_warnings == 0) - warning_at (location, 0, "right shift count >= width " - "of type"); + warning_at (location, OPT_Wshift_count_overflow, + "right shift count >= width of type"); } } } @@ -10545,15 +10546,16 @@ build_binary_op (location_t location, enum tree_code code, { int_const = false; if (c_inhibit_evaluation_warnings == 0) - warning_at (location, 0, "left shift count is negative"); + warning_at (location, OPT_Wshift_count_negative, + "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_at (location, 0, "left shift count >= width of " - "type"); + warning_at (location, OPT_Wshift_count_overflow, + "left shift count >= width of type"); } } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dd0dc2f..22b013e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2014-11-10 Paolo Carlini <paolo.carlini@oracle.com> + + * typeck.c (cp_build_binary_op): Use OPT_Wshift_count_negative and + OPT_Wshift_count_overflow in the warnings. + 2014-11-09 Jason Merrill <jason@redhat.com> DR 799 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d0f5ccd..1f443ef 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4280,14 +4280,16 @@ cp_build_binary_op (location_t location, { if ((complain & tf_warning) && c_inhibit_evaluation_warnings == 0) - warning (0, "right shift count is negative"); + warning (OPT_Wshift_count_negative, + "right shift count is negative"); } else { if (compare_tree_int (const_op1, TYPE_PRECISION (type0)) >= 0 && (complain & tf_warning) && c_inhibit_evaluation_warnings == 0) - warning (0, "right shift count >= width of type"); + warning (OPT_Wshift_count_overflow, + "right shift count >= width of type"); } } /* Convert the shift-count to an integer, regardless of @@ -4328,14 +4330,16 @@ cp_build_binary_op (location_t location, { if ((complain & tf_warning) && c_inhibit_evaluation_warnings == 0) - warning (0, "left shift count is negative"); + warning (OPT_Wshift_count_negative, + "left shift count is negative"); } else if (compare_tree_int (const_op1, TYPE_PRECISION (type0)) >= 0) { if ((complain & tf_warning) && c_inhibit_evaluation_warnings == 0) - warning (0, "left shift count >= width of type"); + warning (OPT_Wshift_count_overflow, + "left shift count >= width of type"); } } /* Convert the shift-count to an integer, regardless of diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 57666db..cd20b6e 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -269,6 +269,7 @@ Objective-C and Objective-C++ Dialects}. -Wpointer-arith -Wno-pointer-to-int-cast @gol -Wredundant-decls -Wno-return-local-addr @gol -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol +-Wshift-count-negative -Wshift-count-overflow @gol -Wsign-compare -Wsign-conversion -Wfloat-conversion @gol -Wsizeof-pointer-memaccess -Wsizeof-array-argument @gol -Wstack-protector -Wstack-usage=@var{len} -Wstrict-aliasing @gol @@ -3825,6 +3826,16 @@ exceptions are @samp{main} and functions defined in system headers. This warning is enabled by @option{-Wall}. +@item -Wshift-count-negative +@opindex Wshift-count-negative +@opindex Wno-shift-count-negative +Warn if shift count is negative. This warning is enabled by default. + +@item -Wshift-count-overflow +@opindex Wshift-count-overflow +@opindex Wno-shift-count-overflow +Warn if shift count >= width of type. This warning is enabled by default. + @item -Wswitch @opindex Wswitch @opindex Wno-switch diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f14bb77..b842138 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-11-10 Paolo Carlini <paolo.carlini@oracle.com> + + * c-c++-common/Wshift-count-overflow-1.c: New. + * c-c++-common/Wshift-count-overflow-2.c: Likewise. + * c-c++-common/Wshift-count-negative-1.c: Likewise. + * c-c++-common/Wshift-count-negative-2.c: Likewise. + 2014-11-10 Andreas Tobler <andreast@gcc.gnu.org> * gcc.dg/fshort-wchar.c: Use arm_eabi instead of arm*-*-*eabi*. diff --git a/gcc/testsuite/c-c++-common/Wshift-count-negative-1.c b/gcc/testsuite/c-c++-common/Wshift-count-negative-1.c new file mode 100644 index 0000000..d883393 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wshift-count-negative-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Wshift-count-negative" } */ + +void foo() +{ + unsigned i1 = 1U << -1; /* { dg-warning "left shift count is negative" } */ + unsigned i2 = 1U >> -1; /* { dg-warning "right shift count is negative" } */ +} diff --git a/gcc/testsuite/c-c++-common/Wshift-count-negative-2.c b/gcc/testsuite/c-c++-common/Wshift-count-negative-2.c new file mode 100644 index 0000000..91c7129 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wshift-count-negative-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-shift-count-negative" } */ + +void foo() +{ + unsigned i1 = 1U << -1; + unsigned i2 = 1U >> -1; +} diff --git a/gcc/testsuite/c-c++-common/Wshift-count-overflow-1.c b/gcc/testsuite/c-c++-common/Wshift-count-overflow-1.c new file mode 100644 index 0000000..4d29d57 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wshift-count-overflow-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Wshift-count-overflow" } */ + +void foo() +{ + unsigned i1 = 1U << (sizeof(unsigned) * __CHAR_BIT__); /* { dg-warning "left shift count >= width of type" } */ + unsigned i2 = 1U >> (sizeof(unsigned) * __CHAR_BIT__); /* { dg-warning "right shift count >= width of type" } */ +} diff --git a/gcc/testsuite/c-c++-common/Wshift-count-overflow-2.c b/gcc/testsuite/c-c++-common/Wshift-count-overflow-2.c new file mode 100644 index 0000000..92032c0 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wshift-count-overflow-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-shift-count-overflow" } */ + +void foo() +{ + unsigned i1 = 1U << (sizeof(unsigned) * __CHAR_BIT__); + unsigned i2 = 1U >> (sizeof(unsigned) * __CHAR_BIT__); +} |