https://gcc.gnu.org/g:fd00010ba21c04bddb20aef52f62de5636075067

commit r15-7552-gfd00010ba21c04bddb20aef52f62de5636075067
Author: Thomas Koenig <tkoe...@gcc.gnu.org>
Date:   Sat Feb 15 11:38:05 2025 +0100

    Fix PR 118884, Lapack build failure.
    
    The fix for PR 118845 introduced new checks, which in turn exposed
    a case where the typespec information on a symbol generated symbol
    was not set.  This led to an apparent type of BT_UNKNOWN, and hence
    an error.  Fixed as obvoius and simple.
    
    gcc/fortran/ChangeLog:
    
            * frontend-passes.cc (check_externals_procedure): Copy
            typespec from old to new symbol.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/interface_54.f90: New test.

Diff:
---
 gcc/fortran/frontend-passes.cc             |  1 +
 gcc/testsuite/gfortran.dg/interface_54.f90 | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc
index 6b470b83e21a..20bf6e127ffc 100644
--- a/gcc/fortran/frontend-passes.cc
+++ b/gcc/fortran/frontend-passes.cc
@@ -5727,6 +5727,7 @@ check_externals_procedure (gfc_symbol *sym, locus *loc,
   gcc_assert (new_sym);
   new_sym->attr = sym->attr;
   new_sym->attr.if_source = IFSRC_DECL;
+  new_sym->ts = sym->ts;
   gfc_current_ns = gsym->ns;
 
   gfc_get_formal_from_actual_arglist (new_sym, actual);
diff --git a/gcc/testsuite/gfortran.dg/interface_54.f90 
b/gcc/testsuite/gfortran.dg/interface_54.f90
new file mode 100644
index 000000000000..98318cae8881
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/interface_54.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR 118884 - this used to be rejected due to confused interface
+! checking.
+
+subroutine cget24
+  external cslect
+  logical cslect
+
+  call cgeesx(cslect)
+  if( cslect() ) print *,"foo"
+  call cgeesx(cslect)
+end subroutine cget24

Reply via email to