From: Martin Sebor Date: Thu, 3 Dec 2020 00:29:59 +0000 (-0700) Subject: Adjust tests even more to avoid ILP32 failures after r11-5622 (PR middle-end/97373) X-Git-Tag: upstream/12.2.0~11264 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5106ff7e6095a281de4c4eead6a3a69a7c59f882;p=platform%2Fupstream%2Fgcc.git Adjust tests even more to avoid ILP32 failures after r11-5622 (PR middle-end/97373) gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Adjust expected warnings to correctly reflect the maximum object size. * gcc.dg/tree-ssa/builtin-sprintf-warn-11.c: Same. * gcc.dg/tree-ssa/builtin-sprintf-warn-18.c: Same. --- 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 3d238c4..0cc03ff 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 @@ -112,24 +112,21 @@ void test_sprintf_c_const (void) T ( 3, "%1$c%2$c", '1', '2'); /* Verify that a warning is issued for exceeding INT_MAX bytes and - not otherwise. In ILP32 where the maximum object size is INT_MAX - 1 - bytes, the calls are diagnosed due to the overflow. */ - T (-1, "%*c", INT_MAX - 2, '1'); - T (-1, "%*c", INT_MAX - 1, '1'); /* { dg-warning "writing a terminating nul past the end" "ilp32" { target ilp32 } } */ - T (-1, "%*c", INT_MAX, '1'); /* { dg-warning "writing 2147483647 bytes into a region of size 2147483646" "il32" { target ilp32 } } */ - T (-1, "X%*c", INT_MAX - 3, '1'); - T (-1, "X%*c", INT_MAX - 1, '1'); /* { dg-warning "writing 2147483646 bytes into a region of size 2147483645" "ilp32" { target ilp32 } } */ + not otherwise. In ILP32 the maximum object size is INT_MAX - 1 + bytes so the calls are diagnosed due to the overflow. */ + T (-1, "%*c", INT_MAX - 1, '1'); + T (-1, "%*c", INT_MAX, '1'); /* { dg-warning "writing a terminating nul past the end " "ilp32" { target ilp32 } } */ + T (-1, "X%*c", INT_MAX - 1, '1'); /* { dg-warning "writing a terminating nul past the end " "ilp32" { target ilp32 } } */ T (-1, "X%*c", INT_MAX, '1'); /* { dg-warning "directive output of \[0-9\]+ bytes causes result to exceed .INT_MAX." "lp64" { target lp64 } } */ - /* { dg-warning "directive writing 2147483647 bytes into a region of size 2147483645." "lp32" { target ilp32 } .-1 } */ + /* { dg-warning "directive writing 2147483647 bytes into a region of size 2147483646" "ilp32" { target ilp32 } .-1 } */ T (-1, "%*c%*c", INT_MAX - 1, '1', INT_MAX - 1, '2'); /* { dg-warning "directive output of \[0-9\]+ bytes causes result to exceed .INT_MAX." "lp64" { target lp64 } } */ - /* { dg-warning "directive writing 2147483646 bytes into a region of size 0" "ilp32" { target ilp32 } .-1 } */ + /* { dg-warning "directive writing 2147483646 bytes into a region of size 1" "ilp32" { target ilp32 } .-1 } */ - T (-1, "%*cX", INT_MAX - 3, '1'); - T (-1, "%*cX", INT_MAX - 2, '1'); /* { dg-warning "writing a terminating nul past the end of the destination" "ilp32" { target ilp32} } */ - T (-1, "%*cX", INT_MAX - 1, '1'); /* { dg-warning "'X' directive writing 1 byte into a region of size 0" "ilp32" { target ilp32 } } */ + T (-1, "%*cX", INT_MAX - 2, '1'); + T (-1, "%*cX", INT_MAX - 1, '1'); /* { dg-warning "writing a terminating nul past the end of the destination" "ilp32" { target ilp32 } } */ T (-1, "%*cX", INT_MAX, '1'); /* { dg-warning "output of \[0-9\]+ bytes causes result to exceed .INT_MAX." "lp64" { target lp64 } } */ - /* { dg-warning "directive writing 2147483647 bytes into a region of size 2147483646" "ilp32" { target ilp32 } .-1 } */ + /* { dg-warning "directive writing 1 byte into a region of size 0" "ilp32" { target ilp32 } .-1 } */ } /* Verify that no warning is issued for calls that write into a flexible @@ -294,11 +291,10 @@ void test_sprintf_chk_s_const (void) /* Verify that output in excess of INT_MAX bytes is diagnosed even when the size of the destination object is unknown. */ - T (-1, "%*s", INT_MAX - 2, ""); - T (-1, "%*s", INT_MAX - 1, ""); /* { dg-warning "writing a terminating nul past the end of the destination" "ilp32" { target ilp32 } } */ - T (-1, "%*s", INT_MAX, ""); /* { dg-warning "directive writing 2147483647 bytes into a region of size 2147483646" "ilp32" { target ilp32 } } */ + T (-1, "%*s", INT_MAX - 1, ""); + T (-1, "%*s", INT_MAX, ""); /* { dg-warning "writing a terminating nul past the end" "ilp32" { target ilp32 } } */ T (-1, "X%*s", INT_MAX, ""); /* { dg-warning "directive output of \[0-9\]+ bytes causes result to exceed .INT_MAX." "lp64" { target lp64 } } */ - /* { dg-warning "directive writing 2147483647 bytes into a region of size 2147483645" "ilp32" { target ilp32 } .-1 } */ + /* { dg-warning "directive writing 2147483647 bytes into a region of size 2147483646" "ilp32" { target ilp32 } .-1 } */ /* Multiple directives. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-11.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-11.c index 22f286d..134967d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-11.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-11.c @@ -197,23 +197,21 @@ void test_narrow_string_with_width_and_precision (void) IR (imax / 9, imax / 8), IR (imax / 7, imax / 6), SR (x, y), IR (imax / 5, imax / 4), IR (imax / 3, imax / 2), SR (x, y)); - /* The two directives below combined convert to [INT_MAX, INT_MAX + 1]. + /* The two directives below combined convert to [INT_MAX -1, INT_MAX + 1]. Since the lower end of the range doesn't exceed INT_MAX no warning - is expected in LP64. In ILP32 where the maximum object size is - INT_MAX - 1, the call is diagnosed. */ + is expected. */ T (-1, "%*.*s%*.*s", IR (imax - 6, imax - 3), IR (1, 2), SR (x, y), - IR ( 4, 6), IR (3, 4), SR (x, y)); - T (-1, "%*.*s%*.*s", - IR (imax - 5, imax - 3), IR (1, 2), SR (x, y), IR ( 5, 6), IR (3, 4), SR (x, y)); - /* { dg-warning "directive writing between 5 and 6 bytes into a region of size between 2 and 4" "ilp32" { target ilp32 } .-3 } */ /* The three directives below (the two %s plus the space in between) combined convert to [INT_MAX + 1, INT_MAX + 2]. Since the lower - end of the range exceeds INT_MAX a warning is expected. */ - T (-1, "%*.*s %*.*s", /* { dg-warning "INT_MAX" "lp64" { target lp64 } } */ - /* { dg-warning "directive writing between 5 and 6 bytes into a region of size between 1 and 3" "ilp32" { target ilp32 } .-1 } */ + end of the range exceeds INT_MAX a warning is expected. In ILP32, + the output overflows the maximum object size. */ + T (-1, "%*.*s %*.*s", + /* { dg-warning "INT_MAX" "LP64" { target lp64 } .-1 } + { dg-warning "directive writing between 5 and 6 bytes into a region of size between 2 and 4" "ILP32" { target ilp32 } .-2 } + */ IR (imax - 5, imax - 3), IR (1, 2), SR (x, y), IR ( 5, 6), IR (3, 4), SR (x, y)); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-18.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-18.c index d30775d..2c410b1 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-18.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-18.c @@ -117,10 +117,10 @@ void test_width_and_precision_out_of_range (char *d) { /* The range here happens to be a property of the compiler, not one of the target. */ - T ("%9223372036854775808i", 0); /* { dg-warning "width out of range" "first" } */ - /* { dg-warning "directive writing \\d+ bytes into a region of size \\d+" "second" { target *-*-* } .-1 } */ - T ("%.9223372036854775808i", 0); /* { dg-warning "precision out of range" "first" } */ - /* { dg-warning "directive writing \\d+ bytes into a region of size \\d+" "second" { target *-*-* } .-1 } */ + T ("%9223372036854775808i", 0); /* { dg-warning "width out of range|exceeds 'INT_MAX'" "first" } */ + /* { dg-warning "directive writing \\d+ bytes into a region of size \\d+" "" { target ilp32 } .-1 } */ + T ("%.9223372036854775808i", 0); /* { dg-warning "precision out of range|exceeds 'INT_MAX'" "first" } */ + /* { dg-warning "directive writing \\d+ bytes into a region of size \\d+" "ilp32" { target ilp32 } .-1 } */ /* The following is diagnosed by -Wformat (disabled here). */ /* T ("%9223372036854775808$i", 0); */