]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: follow-up fix to checking of renamed-on-use interface name [PR120784]
authorHarald Anlauf <anlauf@gmx.de>
Fri, 27 Jun 2025 21:00:48 +0000 (23:00 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Fri, 27 Jun 2025 21:00:48 +0000 (23:00 +0200)
Commit r16-1633 introduced a regression for imported interfaces that were
not renamed-on-use, since the related logic did not take into account that
the absence of renaming could be represented by an empty string.

PR fortran/120784

gcc/fortran/ChangeLog:

* interface.cc (gfc_match_end_interface): Detect empty local_name.

gcc/testsuite/ChangeLog:

* gfortran.dg/interface_63.f90: Extend testcase.

gcc/fortran/interface.cc
gcc/testsuite/gfortran.dg/interface_63.f90

index cdb838d8336895bee3f04aeac21f5cc26cf1072a..f74fbf0f6e587479c3712124178f2d3bf6d9616f 100644 (file)
@@ -457,7 +457,9 @@ gfc_match_end_interface (void)
 
       if (current_interface.sym->attr.use_assoc
          && current_interface.sym->attr.use_rename
-         && current_interface.sym->ns->use_stmts->rename)
+         && current_interface.sym->ns->use_stmts->rename
+         && (current_interface.sym->ns->use_stmts->rename->local_name[0]
+             != '\0'))
        local_name = current_interface.sym->ns->use_stmts->rename->local_name;
 
       if (type != current_interface.type
index a55e8ab431b155ec82980faddea8c99a0f1234e4..56c1644ed8221a8f75db7b783d6570a1902cd297 100644 (file)
@@ -60,3 +60,38 @@ program p
   call myget (i)
   call myget (r)
 end
+
+! Check that we do not regress on the following:
+
+module mod1
+  implicit none
+
+  interface local
+    module procedure local_data
+  end interface local
+
+contains
+
+  logical function local_data (data) result (local)
+    real, intent(in) :: data
+    local = .true.
+  end function local_data
+
+end module mod1
+
+module mod2
+  use mod1, only: local
+  implicit none
+
+  interface local
+     module procedure local_invt
+  end interface local
+
+contains
+
+  logical function local_invt (invt) result (local)
+    integer, intent(in) :: invt
+    local = .true.
+  end function local_invt
+
+end module mod2