https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108544

--- Comment #2 from anlauf at gcc dot gnu.org ---
I played a little and found a variation of testcase pr96102.f90
that was silently accepted but is rejected by Intel, NAG, Cray, NVidia:

module m
  type mytype
    integer :: i
  end type
  type(mytype) :: d = mytype (42) ! { dg-error "is host associated" }
  integer      :: n = 2           ! { dg-error "is host associated" }
contains
  subroutine s
    if ( n   /= 0 ) stop 1  ! { dg-error "internal procedure of the same name"
}
    if ( d%i /= 0 ) stop 2  ! { dg-error "internal procedure of the same name"
}
  contains
    subroutine n()
    end
    subroutine d()
    end
  end
end

This need removing just one line of code in addition to comment#1:

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 94213cd3cd4..b40e04513b5 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -6087,7 +6093,6 @@ check_host_association (gfc_expr *e)
       gfc_find_symbol (e->symtree->name, gfc_current_ns, 1, &sym);

       if (sym && old_sym != sym
-             && sym->ts.type == old_sym->ts.type
              && sym->attr.flavor == FL_PROCEDURE
              && sym->attr.contained)
        {
@@ -6132,6 +6137,9 @@ check_host_association (gfc_expr *e)
                  return false;
                }

+             if (ref == NULL)
+               return false;
+
              gcc_assert (ref->type == REF_ARRAY);

              /* Grab the start expressions from the array ref and

Am I missing something?

Reply via email to