aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2020-07-21 21:37:30 +0200
committerHarald Anlauf <anlauf@gmx.de>2020-07-21 21:37:30 +0200
commit28f2a080cc27531a8c78aec9f44aeff4961c2a4c (patch)
tree405b2e48d96d5082075e159f946027ce292d2312 /gcc
parent02363d5fdb862a11e6e65ac5b0d1f5ee0c422dc3 (diff)
downloadgcc-28f2a080cc27531a8c78aec9f44aeff4961c2a4c.zip
gcc-28f2a080cc27531a8c78aec9f44aeff4961c2a4c.tar.gz
gcc-28f2a080cc27531a8c78aec9f44aeff4961c2a4c.tar.bz2
PR fortran/89574 - ICE in conv_function_val, at fortran/trans-expr.c:3792
When checking for an external procedure from the same file, do not consider symbols from different modules. gcc/fortran/ PR fortran/89574 * trans-decl.c (gfc_get_extern_function_decl): Check whether a symbol belongs to a different module.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/trans-decl.c7
-rw-r--r--gcc/testsuite/gfortran.dg/pr89574.f9029
2 files changed, 35 insertions, 1 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 769ab20..45a739a 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -2090,12 +2090,17 @@ gfc_get_extern_function_decl (gfc_symbol * sym, gfc_actual_arglist *actual_args)
if (gsym && !gsym->bind_c)
gsym = NULL;
}
- else
+ else if (sym->module == NULL)
{
gsym = gfc_find_gsymbol (gfc_gsym_root, sym->name);
if (gsym && gsym->bind_c)
gsym = NULL;
}
+ else
+ {
+ /* Procedure from a different module. */
+ gsym = NULL;
+ }
if (gsym && !gsym->defined)
gsym = NULL;
diff --git a/gcc/testsuite/gfortran.dg/pr89574.f90 b/gcc/testsuite/gfortran.dg/pr89574.f90
new file mode 100644
index 0000000..48dd068
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr89574.f90
@@ -0,0 +1,29 @@
+! { dg-do compile }
+! PR fortran/89574 - ICE in conv_function_val, at fortran/trans-expr.c:3792
+
+module mod1
+contains
+ subroutine init
+ end subroutine
+end module
+
+module mod2
+contains
+ subroutine init
+ end subroutine
+end module
+
+module init
+ use mod1, only : test_init1 => init
+ use mod2, only : test_init2 => init
+ implicit none
+contains
+ subroutine sub
+ call test_init1
+ call test_init2
+ call init
+ contains
+ subroutine init
+ end subroutine
+ end subroutine
+end module