PR middle-end/77721 - -Wformat-length not uses arg range for converted vars

gcc/testsuite/ChangeLog:
	PR middle-end/77721
	* gcc.dg/tree-ssa/builtin-sprintf-warn-6.c: New test.

From-SVN: r240595
This commit is contained in:
Martin Sebor 2016-09-28 19:51:08 +00:00 committed by Martin Sebor
parent 5fe39ec007
commit 88000fd1dc
2 changed files with 97 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2016-09-28 Martin Sebor <msebor@redhat.com>
PR middle-end/77721
* gcc.dg/tree-ssa/builtin-sprintf-warn-6.c: New test.
2016-09-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/77707

View File

@ -0,0 +1,92 @@
/* PR middle-end/77721 - -Wformat-length not uses arg range for converted vars
Test to verify that the correct range information is made available to the
-Wformat-lenght check to prevent warnings. */
/* { dg-do compile } */
/* { dg-options "-O2 -Wformat -Wformat-length" } */
int snprintf (char*, __SIZE_TYPE__, const char*, ...);
void fuchar (unsigned char j, char *p)
{
if (j > 99)
return;
snprintf (p, 4, "%3hu", j);
}
void fschar (signed char j, char *p)
{
const unsigned char k = (unsigned char) j;
if (k > 99)
return;
snprintf (p, 3, "%3hhu", k); /* { dg-bogus "" "unsigned char" { xfail *-*-* } } */
}
void fushrt (unsigned short j, char *p)
{
if (j > 999)
return;
snprintf (p, 4, "%3hu", j);
}
void fshrt (short j, char *p)
{
const unsigned short k = (unsigned short) j;
if (k > 999)
return;
snprintf (p, 4, "%3hu", k);
}
void fuint (unsigned j, char *p)
{
if (j > 999)
return;
snprintf (p, 4, "%3u", j);
}
void fint (int j, char *p)
{
const unsigned k = (unsigned) j;
if (k > 999)
return;
snprintf (p, 4, "%3u", k); /* { dg-bogus "" "unsigned int" { xfail *-*-* } } */
}
void fulong (unsigned long j, char *p)
{
if (j > 999)
return;
snprintf (p, 4, "%3lu", j);
}
void flong (long j, char *p)
{
const unsigned long k = (unsigned long) j;
if (k > 999)
return;
snprintf (p, 4, "%3lu", k); /* { dg-bogus "" "unsigned long" { xfail *-*-* } } */
}
void fullong (unsigned long long j, char *p)
{
if (j > 999)
return;
snprintf (p, 4, "%3llu", j);
}
void fllong (long j, char *p)
{
const unsigned long long k = (unsigned long long) j;
if (k > 999)
return;
snprintf (p, 4, "%3llu", k); /* { dg-bogus "" "unsigned long long" { xfail *-*-* } } */
}