[gcc r17-3288] testsuite/gfortran.dg: Gate tests on effective_target fd_truncate

Hans-Peter Nilsson via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:478c1857b4afb88d7f69a4c79158350908fa8eed

commit r17-3288-g478c1857b4afb88d7f69a4c79158350908fa8eed
Author: Hans-Peter Nilsson <[email protected]>
Date:   Fri Aug 14 01:33:12 2026 +0000

    testsuite/gfortran.dg: Gate tests on effective_target fd_truncate
    
    I usually spot these kind of test-case warts not when tests are added,
    i.e. failing at introduction for non-fd_truncate targets such as
    cris-elf, but only when tests appear to regress, such as was recently
    the case for namelist_101.f90.  That test had a typo corrected in its
    dg-do directive, such that it actually became dg-do run instead of
    just defaulting to dg-do compile, and then failed because the
    formatting ends up calling raw_truncate, triggering the self-marking
    output.
    
    To wit, without this patch, the edited test-cases fail for
    non-effective-target fd_truncate targets, i.e. targets that don't
    support chsize or ftruncate.  See also
    libgfortran/io/unix.c:raw_truncate.  Similar changes where done in
    2008, 2019, and 2024.
    
    2026-08-14  Hans-Peter Nilsson  <[email protected]>
    
            * gfortran.dg/endfile_5.f90, gfortran.dg/namelist_101.f90,
            gfortran.dg/namelist_104.f90, gfortran.dg/unsigned_10.f90,
            gfortran.dg/unsigned_2.f90, gfortran.dg/unsigned_5.f90,
            gfortran.dg/utf8_3.f03: Gate test on effective_target
            fd_truncate.

Diff:
---
 gcc/testsuite/gfortran.dg/endfile_5.f90    | 2 +-
 gcc/testsuite/gfortran.dg/namelist_101.f90 | 2 +-
 gcc/testsuite/gfortran.dg/namelist_104.f90 | 2 +-
 gcc/testsuite/gfortran.dg/unsigned_10.f90  | 2 +-
 gcc/testsuite/gfortran.dg/unsigned_2.f90   | 2 +-
 gcc/testsuite/gfortran.dg/unsigned_5.f90   | 2 +-
 gcc/testsuite/gfortran.dg/utf8_3.f03       | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/gfortran.dg/endfile_5.f90 b/gcc/testsuite/gfortran.dg/endfile_5.f90
index 90eaa6b2e5b9..c56da4cd2273 100644
--- a/gcc/testsuite/gfortran.dg/endfile_5.f90
+++ b/gcc/testsuite/gfortran.dg/endfile_5.f90
@@ -1,4 +1,4 @@
-! { dg-do run }
+! { dg-do run { target fd_truncate } }
 ! PR107031 Check that endfile truncates at end of record 5.
 program test_truncate
     integer :: num_rec, tmp, i, nr, j
diff --git a/gcc/testsuite/gfortran.dg/namelist_101.f90 b/gcc/testsuite/gfortran.dg/namelist_101.f90
index e6b33f876193..04f86e25ca46 100644
--- a/gcc/testsuite/gfortran.dg/namelist_101.f90
+++ b/gcc/testsuite/gfortran.dg/namelist_101.f90
@@ -1,4 +1,4 @@
-! { dg-do run }
+! { dg-do run { target fd_truncate } }
 ! { dg-shouldfail "Missing quote" }
 !
 ! PR libfortran/118793
diff --git a/gcc/testsuite/gfortran.dg/namelist_104.f90 b/gcc/testsuite/gfortran.dg/namelist_104.f90
index d45c07a762ba..023be3048d77 100644
--- a/gcc/testsuite/gfortran.dg/namelist_104.f90
+++ b/gcc/testsuite/gfortran.dg/namelist_104.f90
@@ -1,4 +1,4 @@
-! { dg-do run }
+! { dg-do run { target fd_truncate } }
 ! { dg-shouldfail "Missing quote" }
 !! PR118793 - Expanded namelist error messages
 !
diff --git a/gcc/testsuite/gfortran.dg/unsigned_10.f90 b/gcc/testsuite/gfortran.dg/unsigned_10.f90
index df9167649fe4..a05df6ebc4a0 100644
--- a/gcc/testsuite/gfortran.dg/unsigned_10.f90
+++ b/gcc/testsuite/gfortran.dg/unsigned_10.f90
@@ -1,4 +1,4 @@
-! { dg-do run }
+! { dg-do run { target fd_truncate } }
 ! { dg-options "-funsigned" }
 ! Test I/O with Z, O and B descriptors.
 
diff --git a/gcc/testsuite/gfortran.dg/unsigned_2.f90 b/gcc/testsuite/gfortran.dg/unsigned_2.f90
index 499fd164786b..76592c863a40 100644
--- a/gcc/testsuite/gfortran.dg/unsigned_2.f90
+++ b/gcc/testsuite/gfortran.dg/unsigned_2.f90
@@ -1,4 +1,4 @@
-! { dg-do run }
+! { dg-do run { target fd_truncate } }
 ! { dg-options "-funsigned" }
 ! Test some list-directed I/O
 program main
diff --git a/gcc/testsuite/gfortran.dg/unsigned_5.f90 b/gcc/testsuite/gfortran.dg/unsigned_5.f90
index b8b956ecdf67..ce03215ee010 100644
--- a/gcc/testsuite/gfortran.dg/unsigned_5.f90
+++ b/gcc/testsuite/gfortran.dg/unsigned_5.f90
@@ -1,4 +1,4 @@
-! { dg-do run }
+! { dg-do run { target fd_truncate } }
 ! { dg-options "-funsigned" }
 ! Test conversions from unsigned to different data types by
 ! doing some I/O.
diff --git a/gcc/testsuite/gfortran.dg/utf8_3.f03 b/gcc/testsuite/gfortran.dg/utf8_3.f03
index e1688149e5dc..4a7a2554e6d0 100644
--- a/gcc/testsuite/gfortran.dg/utf8_3.f03
+++ b/gcc/testsuite/gfortran.dg/utf8_3.f03
@@ -1,4 +1,4 @@
-! { dg-do run }
+! { dg-do run { target fd_truncate } }
 ! PR118571 UTF-8 output and the A edit descriptor.
 
 program test
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.