re PR c/65179 (Introduce new C warning: -Wshift-negative-value)
authorMarek Polacek <polacek@redhat.com>
Thu, 7 May 2015 19:36:31 +0000 (19:36 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 7 May 2015 19:36:31 +0000 (19:36 +0000)
commit0173bd2a038cbeef871b22b312a6856ab1dcda2a
tree12367850915ce482968be36f7c2f4344d74b5ed5
parentd57c99458933a21fdf94f508191f145ad8d5ec58
re PR c/65179 (Introduce new C warning: -Wshift-negative-value)

PR c/65179
* c-common.c (c_fully_fold_internal): Warn when left shifting a
negative value.
* c.opt (Wshift-negative-value): New option.
* c-opts.c (c_common_post_options): Set warn_shift_negative_value
when -Wextra and C99/C++11 mode.

* c-typeck.c (build_binary_op): Warn when left shifting a negative
value.

* typeck.c (cp_build_binary_op): Warn when left shifting a negative
value.

* doc/invoke.texi: Document -Wshift-negative-value.

* c-c++-common/Wshift-negative-value-1.c: New test.
* testsuite/c-c++-common/Wshift-negative-value-2.c: New test.
* testsuite/c-c++-common/Wshift-negative-value-3.c: New test.
* testsuite/c-c++-common/Wshift-negative-value-4.c: New test.
* testsuite/c-c++-common/Wshift-negative-value-5.c: New test.
* testsuite/c-c++-common/Wshift-negative-value-6.c: New test.
* testsuite/gcc.dg/c90-left-shift-1.c: New test.
* testsuite/gcc.dg/c99-const-expr-7.c: Add dg-error.
* testsuite/gcc.dg/c99-left-shift-1.c: New test.

From-SVN: r222889
20 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
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-negative-value-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wshift-negative-value-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wshift-negative-value-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wshift-negative-value-4.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wshift-negative-value-5.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wshift-negative-value-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c90-left-shift-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c99-const-expr-7.c
gcc/testsuite/gcc.dg/c99-left-shift-1.c [new file with mode: 0644]