aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2007-08-13 21:02:00 +0000
committerPaul Thomas <pault@gcc.gnu.org>2007-08-13 21:02:00 +0000
commiteda0ed2597cfab9c967d229b7df2986ef92e663d (patch)
tree3f83c824eeb73cf13412e3276dbd038231c3b913
parent5a8af0b4ef5b662dca364091fc4d662eca12bb29 (diff)
downloadgcc-eda0ed2597cfab9c967d229b7df2986ef92e663d.zip
gcc-eda0ed2597cfab9c967d229b7df2986ef92e663d.tar.gz
gcc-eda0ed2597cfab9c967d229b7df2986ef92e663d.tar.bz2
re PR fortran/32926 (ICE with external function as argument)
2007-08-13 Paul Thomas <pault@gcc.gnu.org> PR fortran/32926 * match.c (gfc_match_call): Do not create a new symtree in the case where the existing symbol is external and not referenced. 2007-08-13 Paul Thomas <pault@gcc.gnu.org> PR fortran/32926 * gfortran.dg/external_procedures_3.f90: New test. From-SVN: r127398
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/match.c15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/external_procedures_3.f9035
4 files changed, 55 insertions, 6 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 26a0cd2..b6edba4 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
2007-08-13 Paul Thomas <pault@gcc.gnu.org>
+ PR fortran/32926
+ * match.c (gfc_match_call): Do not create a new symtree in the
+ case where the existing symbol is external and not referenced.
+
+2007-08-13 Paul Thomas <pault@gcc.gnu.org>
+
PR fortran/32827
* decl.c (variable_decl): Check for an imported symbol
by looking for its symtree and testing for the imported
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 39e39af..5f56948 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -2333,13 +2333,16 @@ gfc_match_call (void)
if (!sym->attr.generic
&& !sym->attr.subroutine)
{
- /* ...create a symbol in this scope... */
- if (sym->ns != gfc_current_ns
- && gfc_get_sym_tree (name, NULL, &st) == 1)
- return MATCH_ERROR;
+ if (!(sym->attr.external && !sym->attr.referenced))
+ {
+ /* ...create a symbol in this scope... */
+ if (sym->ns != gfc_current_ns
+ && gfc_get_sym_tree (name, NULL, &st) == 1)
+ return MATCH_ERROR;
- if (sym != st->n.sym)
- sym = st->n.sym;
+ if (sym != st->n.sym)
+ sym = st->n.sym;
+ }
/* ...and then to try to make the symbol into a subroutine. */
if (gfc_add_subroutine (&sym->attr, sym->name, NULL) == FAILURE)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2235cff..9595f222 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2007-08-13 Paul Thomas <pault@gcc.gnu.org>
+ PR fortran/32926
+ * gfortran.dg/external_procedures_3.f90: New test.
+
+2007-08-13 Paul Thomas <pault@gcc.gnu.org>
+
PR fortran/32827
* gfortran.dg/import6.f90: New test.
diff --git a/gcc/testsuite/gfortran.dg/external_procedures_3.f90 b/gcc/testsuite/gfortran.dg/external_procedures_3.f90
new file mode 100644
index 0000000..987ba79
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/external_procedures_3.f90
@@ -0,0 +1,35 @@
+! { dg-do run }
+! Tests the fix for PR32926, in which the call to fcn
+! in bar would cause an ICE because it had not been referenced
+! in the namespace where it was declared.
+!
+! Contributed by Ralph Baker Kearfott <rbk@louisiana.edu>
+!
+subroutine foobar1
+ common // chr
+ character(8) :: chr
+ chr = "foobar1"
+end subroutine
+subroutine foobar2
+ common // chr
+ character(8) :: chr
+ chr = "foobar2"
+end subroutine
+
+subroutine foo (fcn)
+ external fcn
+ call bar
+contains
+ subroutine bar
+ call fcn
+ end subroutine bar
+end subroutine foo
+
+ external foo, foobar1, foobar2
+ common // chr
+ character(8) :: chr
+ call foo (foobar1)
+ if (chr .ne. "foobar1") call abort ()
+ call foo (foobar2)
+ if (chr .ne. "foobar2") call abort ()
+end