Commit 3685c5ad by Alexandre Oliva Committed by Alexandre Oliva

introduce target fileio and require it in tests that use tmpnam

Some target C libraries that aren't recognized as freestanding don't
have filesystem support, so calling tmpnam, fopen/open and
remove/unlink fails to link.

This patch introduces a fileio effective target to the testsuite, and
requires it in the tests that call tmpnam.


for  gcc/testsuite/ChangeLog

	* lib/target-supports.exp (check_effective_target_fileio): New.
	* gcc.c-torture/execute/fprintf-2.c: Require it.
	* gcc.c-torture/execute/printf-2.c: Likewise.
	* gcc.c-torture/execute/user-printf.c: Likewise.
parent c508fd07
2020-04-24 Alexandre Oliva <oliva@adacore.com>
* lib/target-supports.exp (check_effective_target_fileio): New.
* gcc.c-torture/execute/fprintf-2.c: Require it.
* gcc.c-torture/execute/printf-2.c: Likewise.
* gcc.c-torture/execute/user-printf.c: Likewise.
2020-04-24 Haijian Zhang <z.zhanghaijian@huawei.com> 2020-04-24 Haijian Zhang <z.zhanghaijian@huawei.com>
PR rtl-optimization/94708 PR rtl-optimization/94708
......
/* Verify that calls to fprintf don't get eliminated even if their /* Verify that calls to fprintf don't get eliminated even if their
result on success can be computed at compile time (they can fail). result on success can be computed at compile time (they can fail).
The calls can still be transformed into those of other functions. The calls can still be transformed into those of other functions.
{ dg-require-effective-target fileio }
{ dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" } { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" }
{ dg-skip-if "requires io" { avr-*-* } } { dg-skip-if "requires io" { avr-*-* } }
{ dg-skip-if "requires io" { freestanding } } */ { dg-skip-if "requires io" { freestanding } } */
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
result on success can be computed at compile time (they can fail). result on success can be computed at compile time (they can fail).
The calls can still be transformed into those of other functions. The calls can still be transformed into those of other functions.
{ dg-require-effective-target unwrapped } { dg-require-effective-target unwrapped }
{ dg-require-effective-target fileio }
{ dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" } { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" }
{ dg-skip-if "requires io" { avr-*-* } } { dg-skip-if "requires io" { avr-*-* } }
{ dg-skip-if "requires io" { freestanding } } */ { dg-skip-if "requires io" { freestanding } } */
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
don't get eliminated even if their result on success can be computed at don't get eliminated even if their result on success can be computed at
compile time (they can fail). compile time (they can fail).
{ dg-require-effective-target unwrapped } { dg-require-effective-target unwrapped }
{ dg-require-effective-target fileio }
{ dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" } { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" }
{ dg-skip-if "requires io" { avr-*-* } } { dg-skip-if "requires io" { avr-*-* } }
{ dg-skip-if "requires io" { freestanding } } */ { dg-skip-if "requires io" { freestanding } } */
......
...@@ -751,6 +751,19 @@ proc check_effective_target_freestanding { } { ...@@ -751,6 +751,19 @@ proc check_effective_target_freestanding { } {
return 0 return 0
} }
# Check to see that file I/O functions are available.
proc check_effective_target_fileio { } {
return [check_no_compiler_messages fileio_available executable {
#include <stdio.h>
int main() {
char *n = tmpnam (NULL);
FILE *f = fopen (n, "w");
fclose (f);
remove (n);
return 0;
} } ""]
}
# Return 1 if target has packed layout of structure members by # Return 1 if target has packed layout of structure members by
# default, 0 otherwise. Note that this is slightly different than # default, 0 otherwise. Note that this is slightly different than
# whether the target has "natural alignment": both attributes may be # whether the target has "natural alignment": both attributes may be
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment