aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2016-09-28 16:24:35 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2016-09-28 10:24:35 -0600
commit2b1b5938422ef07c10509de00d52b735e55a86f4 (patch)
tree5b9dc746932674688e277de75393c0fa206ceb0f
parent30dc6ee97026f393813f0a31f2294ac1d0898c56 (diff)
downloadgcc-2b1b5938422ef07c10509de00d52b735e55a86f4.zip
gcc-2b1b5938422ef07c10509de00d52b735e55a86f4.tar.gz
gcc-2b1b5938422ef07c10509de00d52b735e55a86f4.tar.bz2
PR c/77762 - Incorrect destination buffer length in -Wformat-length warning
gcc/testsuite/ChangeLog: PR c/77762 * gcc.dg/tree-ssa/builtin-sprintf-warn-1.c (test_vsnprintf_chk_s): Call __builtin___vsnprintf_chk, not __builtin___snprintf_chk. (test_sprintf_p_const): Adjust line numbers to avoid failures introduced in r240503. gcc/ChangeLog: PR c/77762 * gimple-ssa-sprintf.c (pass_sprintf_length::handle_gimple_call): Fix typos. From-SVN: r240584
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimple-ssa-sprintf.c4
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c10
4 files changed, 21 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 13d0efa..194c9bf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2016-09-28 Martin Sebor <msebor@redhat.com>
+ PR c/77762
+ * gimple-ssa-sprintf.c (pass_sprintf_length::handle_gimple_call):
+ Fix typos.
+
+2016-09-28 Martin Sebor <msebor@redhat.com>
+
PR middle-end/77683
* gimple-ssa-sprintf.c (format_integer): Fail gracefully when
length modifier is not expected.
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index f7382f1..8c92ab1 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -2558,8 +2558,8 @@ pass_sprintf_length::handle_gimple_call (gimple_stmt_iterator gsi)
// Signature:
// __builtin___vsnprintf_chk (dst, size, ost, objsize, format, va)
idx_dstsize = 1;
- idx_objsize = 2;
- idx_format = 3;
+ idx_objsize = 3;
+ idx_format = 4;
info.argidx = -1;
info.bounded = true;
break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0980c54..ee788ee 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,13 @@
2016-09-28 Martin Sebor <msebor@redhat.com>
+ PR c/77762
+ * gcc.dg/tree-ssa/builtin-sprintf-warn-1.c (test_vsnprintf_chk_s):
+ Call __builtin___vsnprintf_chk, not __builtin___snprintf_chk.
+ (test_sprintf_p_const): Adjust line numbers to avoid failures
+ introduced in r240503.
+
+2016-09-28 Martin Sebor <msebor@redhat.com>
+
PR middle-end/77683
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Add test cases.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
index 3a17189..b9acf66 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
@@ -95,7 +95,7 @@ void test_sprintf_p_const (void)
format null pointers as 0 or 0x0 and so the following will only be
diagnosed on the former targets. */
T (5, "%p", (void*)0);
- /* { dg-warning "nul past the end" "(nil)" { target *-linux-gnu *-*-uclinux } 96 } */
+ /* { dg-warning "nul past the end" "(nil)" { target *-linux-gnu *-*-uclinux } .-1 } */
/* The exact output for %p is unspecified by C. Two formats are known:
same as %tx (for example AIX) and same as %#tx (for example Solaris). */
@@ -107,8 +107,8 @@ void test_sprintf_p_const (void)
as with signed integer conversions (i.e., it prepends a space). Other
known implementations ignore it. */
T (6, "% p", (void*)0x234); /* { dg-warning ". . flag used with .%p." } */
- /* { dg-warning "nul past the end" "Glibc %p" { target *-linux-gnu } 108 } */
- /* { dg-warning "nul past the end" "Generic %p" { target *-*-uclinux } 108 } */
+ /* { dg-warning "nul past the end" "Glibc %p" { target *-linux-gnu } .-1 } */
+ /* { dg-warning "nul past the end" "Generic %p" { target *-*-uclinux } .-2 } */
}
/* Verify that no warning is issued for calls that write into a flexible
@@ -1410,9 +1410,9 @@ void test_vsnprintf_chk_s (__builtin_va_list va)
/* Verify that specifying a size of the destination buffer that's
bigger than its actual size (normally determined and passed to
the function by __builtin_object_size) is diagnosed. */
- __builtin___snprintf_chk (buffer, 123, 0, 122, " "); /* { dg-warning "always overflow|specified size 123 exceeds the size 122 of the destination object" } */
+ __builtin___vsnprintf_chk (buffer, 123, 0, 122, "%-s", va); /* { dg-warning "always overflow|specified size 123 exceeds the size 122 of the destination object" } */
- __builtin___snprintf_chk (buffer, __SIZE_MAX__, 0, 2, " "); /* { dg-warning "always overflow|destination size .\[0-9\]+. too large" } */
+ __builtin___vsnprintf_chk (buffer, __SIZE_MAX__, 0, 2, "%-s", va); /* { dg-warning "always overflow|destination size .\[0-9\]+. too large" } */
T (0, "%s");
T (1, "%s");