PR c++/55095
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Jul 2015 13:43:45 +0000 (13:43 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Jul 2015 13:43:45 +0000 (13:43 +0000)
commit8d669e79421bd614d5f7491f064606e6f46e07e8
tree42f1e133920c2d40c48b5953fe8ca2e817aae347
parent5ced42f848b676f2528f544c99283bb49d76c5a6
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225998 138bc75d-0d04-0410-961f-82ee72b054a4
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