From 281ac396d1715da56e1098032de9d0b747fcace9 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 10 Jul 2017 21:00:56 +0000 Subject: [PATCH] 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 --- gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c.opt | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr81345.c | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr81345.c diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7ddf192e496..b21db816b4d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2017-07-10 Martin Sebor + + PR other/81345 + * c.opt (-Wstringop-overflow): Set defaults in LangEnabledBy. + 2017-07-06 David Malcolm * c-common.c (selftest::c_family_tests): New. diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 05766c47856..e0ad3ab10b8 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 98d9d1c14ae..9250bca46f2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-10 Martin Sebor + + PR other/81345 + * gcc.dg/pr81345.c: New test. + 2017-07-10 Claudiu Zissulescu * 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 00000000000..c2cbad72967 --- /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=]" } */ +} -- 2.30.2