https://gcc.gnu.org/g:8ff212d10acb46c770195af9185396b021f7aa4c

commit r16-6342-g8ff212d10acb46c770195af9185396b021f7aa4c
Author: Steve Kargl <[email protected]>
Date:   Sun Dec 21 18:32:46 2025 -0800

    fortran [PR122957] DTIO incompatibility with -fdefault-interger-8
    
    The -fdefault-integer-8 option is optional to assist with legacy
    fortran codes. It is not a Standard requirement and is not
    compatible with the newer user defined derived type I/O.
    
            PR fortran/122957
    
    gcc/fortran/ChangeLog:
    
            * interface.cc (gfc_match_generic_spec): Issue an error
            so that users do not use -fdefault-integer-8 with DTIO.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/pr122957.f90: New test.

Diff:
---
 gcc/fortran/interface.cc               | 13 +++++++++++++
 gcc/testsuite/gfortran.dg/pr122957.f90 | 22 ++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index ef5a17d0af45..5ffec5074ed4 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -211,11 +211,15 @@ gfc_match_generic_spec (interface_type *type,
       *op = dtio_op (buffer);
       if (*op == INTRINSIC_FORMATTED)
        {
+         if (flag_default_integer)
+           goto conflict;
          strcpy (name, gfc_code2string (dtio_procs, DTIO_RF));
          *type = INTERFACE_DTIO;
        }
       if (*op == INTRINSIC_UNFORMATTED)
        {
+         if (flag_default_integer)
+           goto conflict;
          strcpy (name, gfc_code2string (dtio_procs, DTIO_RUF));
          *type = INTERFACE_DTIO;
        }
@@ -228,11 +232,15 @@ gfc_match_generic_spec (interface_type *type,
       *op = dtio_op (buffer);
       if (*op == INTRINSIC_FORMATTED)
        {
+         if (flag_default_integer)
+           goto conflict;
          strcpy (name, gfc_code2string (dtio_procs, DTIO_WF));
          *type = INTERFACE_DTIO;
        }
       if (*op == INTRINSIC_UNFORMATTED)
        {
+         if (flag_default_integer)
+           goto conflict;
          strcpy (name, gfc_code2string (dtio_procs, DTIO_WUF));
          *type = INTERFACE_DTIO;
        }
@@ -250,6 +258,11 @@ gfc_match_generic_spec (interface_type *type,
   *type = INTERFACE_NAMELESS;
   return MATCH_YES;
 
+conflict:
+  gfc_error ("Sorry: -fdefault-integer-8 option is not supported with "
+            "user-defined input/output at %C");
+  return MATCH_ERROR;
+
 syntax:
   gfc_error ("Syntax error in generic specification at %C");
   return MATCH_ERROR;
diff --git a/gcc/testsuite/gfortran.dg/pr122957.f90 
b/gcc/testsuite/gfortran.dg/pr122957.f90
new file mode 100644
index 000000000000..d7b2c5d5c1e9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr122957.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-fdefault-integer-8" }
+
+module mymod 
+  type :: my_type
+    real :: value 
+  end type 
+
+  interface write(formatted) ! { dg-error "is not supported" }
+    module procedure  write_formatted ! { dg-error "a generic module 
interface" }
+  end interface ! { dg-error "Expecting" }
+
+contains
+  subroutine write_formatted(dtv, unit, iotype, v_list, iostat, iomsg)
+    class(my_type), intent(in) :: dtv
+    integer, intent(in) :: unit
+    character(*), intent(in) :: iotype
+    integer, intent(in) :: v_list(:)
+    integer, intent(out) :: iostat
+    character(*), intent(inout) :: iomsg
+  end subroutine write_formatted
+end module

Reply via email to