diff options
author | Martin Sebor <msebor@redhat.com> | 2017-07-10 21:00:56 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2017-07-10 15:00:56 -0600 |
commit | 281ac396d1715da56e1098032de9d0b747fcace9 (patch) | |
tree | b1c9cd4f04d46b6190cfc5170335fe20537273a1 | |
parent | b0e90d2acfd63b8cb2fed2385abb5c034fcd7e9a (diff) | |
download | gcc-281ac396d1715da56e1098032de9d0b747fcace9.zip gcc-281ac396d1715da56e1098032de9d0b747fcace9.tar.gz gcc-281ac396d1715da56e1098032de9d0b747fcace9.tar.bz2 |
PR other/81345 - -Wall resets -Wstringop-overflow to 1 from the default 2
gcc/c-family/ChangeLog:
PR other/81345
* c.opt (-Wstringop-overflow): Set defaults in LangEnabledBy.
gcc/testsuite/ChangeLog:
PR other/81345
* gcc.dg/pr81345.c: New test.
From-SVN: r250104
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr81345.c | 17 |
4 files changed, 28 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7ddf192..b21db81 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2017-07-10 Martin Sebor <msebor@redhat.com> + + PR other/81345 + * c.opt (-Wstringop-overflow): Set defaults in LangEnabledBy. + 2017-07-06 David Malcolm <dmalcolm@redhat.com> * c-common.c (selftest::c_family_tests): New. diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 05766c4..e0ad3ab 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -732,7 +732,7 @@ Warn about buffer overflow in string manipulation functions like memcpy and strcpy. Wstringop-overflow= -C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_stringop_overflow) Init(2) Warning LangEnabledBy(C ObjC C++ ObjC++, Wall) IntegerRange(0, 4) +C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_stringop_overflow) Init(2) Warning LangEnabledBy(C ObjC C++ ObjC++, Wall, 2, 0) IntegerRange(0, 4) Under the control of Object Size type, warn about buffer overflow in string manipulation functions like memcpy and strcpy. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 98d9d1c..9250bca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-10 Martin Sebor <msebor@redhat.com> + + PR other/81345 + * gcc.dg/pr81345.c: New test. + 2017-07-10 Claudiu Zissulescu <claziss@synopsys.com> * gcc.target/arc/mulsi3_highpart-1.c: Remove 'X' constraint. diff --git a/gcc/testsuite/gcc.dg/pr81345.c b/gcc/testsuite/gcc.dg/pr81345.c new file mode 100644 index 0000000..c2cbad7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr81345.c @@ -0,0 +1,17 @@ +/* PR other/81345 - -Wall resets -Wstringop-overflow to 1 from the default 2 + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +char a[3]; + +void f (const char *s) +{ + __builtin_strncpy (a, s, sizeof a + 1); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} + +struct S { char a[3]; int i; }; + +void g (struct S *d, const char *s) +{ + __builtin_strncpy (d->a, s, sizeof d->a + 1); /* { dg-warning "\\\[-Wstringop-overflow=]" } */ +} |