diff options
author | Marek Polacek <polacek@redhat.com> | 2015-05-07 19:36:31 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-05-07 19:36:31 +0000 |
commit | 0173bd2a038cbeef871b22b312a6856ab1dcda2a (patch) | |
tree | 12367850915ce482968be36f7c2f4344d74b5ed5 /gcc/c-family/c-opts.c | |
parent | d57c99458933a21fdf94f508191f145ad8d5ec58 (diff) | |
download | gcc-0173bd2a038cbeef871b22b312a6856ab1dcda2a.zip gcc-0173bd2a038cbeef871b22b312a6856ab1dcda2a.tar.gz gcc-0173bd2a038cbeef871b22b312a6856ab1dcda2a.tar.bz2 |
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
Diffstat (limited to 'gcc/c-family/c-opts.c')
-rw-r--r-- | gcc/c-family/c-opts.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 1a67b5a..a61d6a8 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -866,6 +866,11 @@ c_common_post_options (const char **pfilename) if (warn_implicit_int == -1) warn_implicit_int = flag_isoc99; + /* -Wshift-negative-value is enabled by -Wextra in C99 and C++11 modes. */ + if (warn_shift_negative_value == -1) + warn_shift_negative_value = (extra_warnings + && (cxx_dialect >= cxx11 || flag_isoc99)); + /* Declone C++ 'structors if -Os. */ if (flag_declone_ctor_dtor == -1) flag_declone_ctor_dtor = optimize_size; |