>From 7592d9885306fb6789bd7adc38aa7008ce23308b Mon Sep 17 00:00:00 2001
From: Hans-Peter Nilsson <[email protected]>
Date: Fri, 14 Aug 2026 01:33:12 +0000
Subject: 

Committed as obvious after testing on cris-elf and x86_64-linux,
observing the tests running only where intended.

-- >8 --

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.
---
 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
-- 
2.43.0

Reply via email to