From: Martin Sebor Date: Wed, 28 Sep 2016 16:24:35 +0000 (+0000) Subject: PR c/77762 - Incorrect destination buffer length in -Wformat-length warning X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2b1b5938422ef07c10509de00d52b735e55a86f4;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 13d0efa79d2..194c9bf026c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-09-28 Martin Sebor + + PR c/77762 + * gimple-ssa-sprintf.c (pass_sprintf_length::handle_gimple_call): + Fix typos. + 2016-09-28 Martin Sebor PR middle-end/77683 diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index f7382f10eef..8c92ab1f997 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 0980c5483d0..ee788ee2082 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-09-28 Martin Sebor + + 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 PR middle-end/77683 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 3a171893e81..b9acf660862 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");