re PR c++/55095 (Wshift-overflow)
authorMarek Polacek <polacek@redhat.com>
Mon, 20 Jul 2015 13:43:45 +0000 (13:43 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 20 Jul 2015 13:43:45 +0000 (13:43 +0000)
commit451b5e4830e34b0ee1ae8af9fe3de4afe2fc5631
tree42f1e133920c2d40c48b5953fe8ca2e817aae347
parent7040e90366fe1e8d4d78564335f3b3ea8e55234b
re PR c++/55095 (Wshift-overflow)

PR c++/55095
* c-common.c (c_fully_fold_internal): Warn about left shift overflows.
Use EXPR_LOC_OR_LOC.
(maybe_warn_shift_overflow): New function.
* c-common.h (maybe_warn_shift_overflow): Declare.
* c-opts.c (c_common_post_options): Set warn_shift_overflow.
* c.opt (Wshift-overflow): New option.

* c-typeck.c (digest_init): Pass OPT_Wpedantic to pedwarn_init.
(build_binary_op): Warn about left shift overflows.

* typeck.c (cp_build_binary_op): Warn about left shift overflows.

* doc/invoke.texi: Document -Wshift-overflow and -Wshift-overflow=.

* c-c++-common/Wshift-overflow-1.c: New test.
* c-c++-common/Wshift-overflow-2.c: New test.
* c-c++-common/Wshift-overflow-3.c: New test.
* c-c++-common/Wshift-overflow-4.c: New test.
* c-c++-common/Wshift-overflow-5.c: New test.
* g++.dg/cpp1y/left-shift-1.C: New test.
* gcc.dg/c90-left-shift-2.c: New test.
* gcc.dg/c90-left-shift-3.c: New test.
* gcc.dg/c99-left-shift-2.c: New test.
* gcc.dg/c99-left-shift-3.c: New test.
* gcc.dg/pr40501.c: Use -Wno-shift-overflow.
* gcc.c-torture/execute/pr40386.c: Likewise.
* gcc.dg/vect/pr33373.c: Likewise.
* gcc.dg/vect/vect-shift-2-big-array.c: Likewise.
* gcc.dg/vect/vect-shift-2.c: Likewise.

Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com>
From-SVN: r225998
27 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c-family/c-opts.c
gcc/c-family/c.opt
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wshift-overflow-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wshift-overflow-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wshift-overflow-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wshift-overflow-4.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wshift-overflow-5.c [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/left-shift-1.C [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr40386.c
gcc/testsuite/gcc.dg/c90-left-shift-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c90-left-shift-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c99-left-shift-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c99-left-shift-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr40501.c
gcc/testsuite/gcc.dg/vect/pr33373.c
gcc/testsuite/gcc.dg/vect/vect-shift-2-big-array.c
gcc/testsuite/gcc.dg/vect/vect-shift-2.c