]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
introduce target fileio and require it in tests that use tmpnam
authorAlexandre Oliva <oliva@adacore.com>
Fri, 24 Apr 2020 11:32:10 +0000 (08:32 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Fri, 24 Apr 2020 11:32:10 +0000 (08:32 -0300)
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.

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/fprintf-2.c
gcc/testsuite/gcc.c-torture/execute/printf-2.c
gcc/testsuite/gcc.c-torture/execute/user-printf.c
gcc/testsuite/lib/target-supports.exp

index 4b1e9e11e7c852f31b2c122d357d6f3cc8c10c9a..e6b8812061debf305fdb4bc28297163caf50c53b 100644 (file)
@@ -1,3 +1,10 @@
+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>
 
        PR rtl-optimization/94708
index c723867368d2e38d99bb639ef06ec627e422211b..d8e19e7b2f8f51852facdae03724214ce132da84 100644 (file)
@@ -1,6 +1,7 @@
 /* Verify that calls to fprintf don't get eliminated even if their
    result on success can be computed at compile time (they can fail).
    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-skip-if "requires io" { avr-*-* } }
    { dg-skip-if "requires io" { freestanding } } */
index 57f467e0b9cc40be2a72c166b4b0db948e40a854..4e7d8f7cdfad6c6023fc8eae469b9f9a0f290be9 100644 (file)
@@ -2,6 +2,7 @@
    result on success can be computed at compile time (they can fail).
    The calls can still be transformed into those of other functions.
    { dg-require-effective-target unwrapped }
+   { dg-require-effective-target fileio }
    { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" }
    { dg-skip-if "requires io" { avr-*-* } }
    { dg-skip-if "requires io" { freestanding } } */
index 006d99e8dd3089d8ab5c6151741ac1e464b9aa3b..42a3b17f123d13be09c7748eca2da5105bcc9734 100644 (file)
@@ -2,6 +2,7 @@
    don't get eliminated even if their result on success can be computed at
    compile time (they can fail).
    { dg-require-effective-target unwrapped }
+   { dg-require-effective-target fileio }
    { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" }
    { dg-skip-if "requires io" { avr-*-* } }
    { dg-skip-if "requires io" { freestanding } } */
index a667ddf4fe47a6467f58caa486333a0fda2b290a..008def691b34fde971756dbec0ffd3496c6ca9b1 100644 (file)
@@ -751,6 +751,19 @@ proc check_effective_target_freestanding { } {
     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
 # default, 0 otherwise.  Note that this is slightly different than
 # whether the target has "natural alignment": both attributes may be