aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2017-01-11 17:28:52 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2017-01-11 10:28:52 -0700
commitbf5fbf465dee3a30588bc9e6895d50a6f4ca59c5 (patch)
treea4a7ff7d85ae5229e27ef5950d168a127b78b34b
parent19ff0049cd22794359a46c86d34fa19be655ba3d (diff)
downloadgcc-bf5fbf465dee3a30588bc9e6895d50a6f4ca59c5.zip
gcc-bf5fbf465dee3a30588bc9e6895d50a6f4ca59c5.tar.gz
gcc-bf5fbf465dee3a30588bc9e6895d50a6f4ca59c5.tar.bz2
PR c/78768 - -Walloca-larger-than and -Wformat-length warnings disabled by -flto
gcc/ChangeLog: * c.opt (-Walloca-larger-than, -Wformat-length, -Wformat-truncation): Also enable for LTO. gcc/testsuite/ChangeLog: PR c/78768 * gcc.dg/pr78768.c: New test. From-SVN: r244326
-rw-r--r--gcc/c-family/ChangeLog6
-rw-r--r--gcc/c-family/c.opt6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr78768.c13
4 files changed, 27 insertions, 3 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index a7f2f0d..8faecd4 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-11 Martin Sebor <msebor@redhat.com>
+
+ PR c/78768
+ * c.opt (-Walloca-larger-than, -Wformat-length, -Wformat-truncation):
+ Also enable for LTO.
+
2017-01-10 Jason Merrill <jason@redhat.com>
Implement P0195R2, C++17 variadic using.
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 104d816..1b49d21 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -313,7 +313,7 @@ C ObjC C++ ObjC++ Var(warn_alloc_zero) Warning
-Walloc-zero Warn for calls to allocation functions that specify zero bytes.
Walloca-larger-than=
-C ObjC C++ ObjC++ Var(warn_alloca_limit) Warning Joined RejectNegative UInteger
+C ObjC C++ LTO ObjC++ Var(warn_alloca_limit) Warning Joined RejectNegative UInteger
-Walloca-larger-than=<number> Warn on unbounded uses of
alloca, and on bounded uses of alloca whose bound can be larger than
<number> bytes.
@@ -521,7 +521,7 @@ C ObjC C++ ObjC++ Var(warn_format_extra_args) Warning LangEnabledBy(C ObjC C++ O
Warn if passing too many arguments to a function for its format string.
Wformat-length
-C ObjC C++ ObjC++ Warning Alias(Wformat-length=, 1, 0)
+C ObjC C++ LTO ObjC++ Warning Alias(Wformat-length=, 1, 0)
Warn about function calls with format strings that write past the end
of the destination region. Same as -Wformat-length=1.
@@ -538,7 +538,7 @@ C ObjC C++ ObjC++ Var(warn_format_signedness) Warning
Warn about sign differences with format functions.
Wformat-truncation
-C ObjC C++ ObjC++ Warning Alias(Wformat-truncation=, 1, 0)
+C ObjC C++ LTO ObjC++ Warning Alias(Wformat-truncation=, 1, 0)
Warn about calls to snprintf and similar functions that truncate output.
Same as -Wformat-truncation=1.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a4987ca..bd56e7b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-11 Martin Sebor <msebor@redhat.com>
+
+ PR c/78768
+ * gcc.dg/pr78768.c: New test.
+
2017-01-11 David Malcolm <dmalcolm@redhat.com>
PR driver/78877
diff --git a/gcc/testsuite/gcc.dg/pr78768.c b/gcc/testsuite/gcc.dg/pr78768.c
new file mode 100644
index 0000000..e3d16a7e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr78768.c
@@ -0,0 +1,13 @@
+/* PR c/78768 - -Walloca-larger-than and -Wformat-length warnings disabled
+ by -flto
+ { dg-do run }
+ { dg-options "-O2 -Walloca-larger-than=10 -Wformat -Wformat-length -flto" } */
+
+int main (void)
+{
+ char *d = (char *)__builtin_alloca (12); /* { dg-warning "argument to .alloca. is too large" } */
+
+ __builtin_sprintf (d, "%32s", "x"); /* { dg-warning "directive writing 32 bytes into a region of size 12" "-Wformat-length" { xfail *-*-* } } */
+
+ return 0;
+}