Fix bogus builtin-sprintf-warn-{3,10}.c failures for avr.

This patch fixes a whole bunch of failures reported for
gcc.dg/tree-ssa/builtin-sprintf-warn-{3,10}.c for the avr target.

builtin-sprintf-warn-10.c fails because the bounds in the warning
messages expect 4 digit wide exponents i.e. __DBL_MAX_EXP__ > 999.
For the avr, floats and doubles are both 32 bits wide, __DBL_MAX_EXP__
== 128, and the max number of exponent digits can only be 3 .
The computed size thus ends up one short of the value the test
expects. The patch makes the test run only for targets with double64plus.

builtin-sprintf-warn-3.c fails because the test appears to assume all
non lp64 targets to be ilp32. For the avr, pointer size and int size
are equal, but both are 16 bits, not 32. The patch fixes this by
explicitly adding avr to the dejagnu selector.

gcc/testsuite

2017-04-06  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

	* gcc.dg/tree-ssa/builtin-sprintf-warn-10.c: Require double64plus.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c (void test_too_large): 
	Add avr-*-* to non-lp64 selector.

From-SVN: r246831
This commit is contained in:
Senthil Kumar Selvaraj 2017-04-11 05:09:41 +00:00 committed by Senthil Kumar Selvaraj
parent b75179f367
commit abde687ac3
3 changed files with 11 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2017-04-11 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
* gcc.dg/tree-ssa/builtin-sprintf-warn-10.c: Require double64plus.
* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c (void test_too_large):
Add avr-*-* to non-lp64 selector.
2017-04-10 Martin Sebor <msebor@redhat.com>
* gcc.dg/pr40340-3.c: Adjust directive pattern.

View File

@ -2,6 +2,7 @@
Test to verify the correctness of ranges of output computed for floating
point directives.
{ dg-do compile }
{ dg-require-effective-target double64plus }
{ dg-options "-O2 -Wformat -Wformat-overflow -ftrack-macro-expansion=0" } */
typedef __builtin_va_list va_list;

View File

@ -358,19 +358,19 @@ void test_too_large (char *d, int x, __builtin_va_list va)
__builtin_snprintf (d, imax, "%c", x);
__builtin_snprintf (d, imax_p1, "%c", x); /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target lp64 } } */
/* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { ilp32 } } .-1 } */
/* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { avr-*-* } || ilp32 } } .-1 } */
__builtin_vsnprintf (d, imax, "%c", va);
__builtin_vsnprintf (d, imax_p1, "%c", va); /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target lp64 } } */
/* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { ilp32 } } .-1 } */
/* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { avr-*-* } || ilp32 } } .-1 } */
__builtin___snprintf_chk (d, imax, 0, imax, "%c", x);
__builtin___snprintf_chk (d, imax_p1, 0, imax_p1, "%c", x); /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target lp64 } } */
/* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { ilp32 } } .-1 } */
/* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { avr-*-* } || ilp32 } } .-1 } */
__builtin___vsnprintf_chk (d, imax, 0, imax, "%c", va);
__builtin___vsnprintf_chk (d, imax_p1, 0, imax_p1, "%c", va); /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target lp64 } } */
/* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { ilp32 } } .-1 } */
/* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { avr-*-* } || ilp32 } } .-1 } */
const size_t ptrmax = __PTRDIFF_MAX__;
const size_t ptrmax_m1 = ptrmax - 1;