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
This commit is contained in:
Martin Sebor 2016-09-28 16:24:35 +00:00 committed by Martin Sebor
parent 30dc6ee970
commit 2b1b593842
4 changed files with 21 additions and 7 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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;

View File

@ -1,3 +1,11 @@
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

View File

@ -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");