OSDN Git Service

2009-01-10 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 10 Jan 2009 00:11:18 +0000 (00:11 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 10 Jan 2009 00:11:18 +0000 (00:11 +0000)
PR fortran/38765
* resolve.c (check_host_association): Use the symtree name to
search for a potential contained procedure, since this is the
name by which it would be referenced.

2009-01-10  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/38765
* gfortran.dg/host_assoc_function_6.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143237 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/host_assoc_function_6.f90 [new file with mode: 0644]

index 84b81e2..b7d1b99 100644 (file)
@@ -1,3 +1,10 @@
+2009-01-10  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/38765
+       * resolve.c (check_host_association): Use the symtree name to
+       search for a potential contained procedure, since this is the
+       name by which it would be referenced.
+
 2009-01-06  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/38220
 2009-01-06  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/38220
index 0cdf40e..3148b0d 100644 (file)
@@ -1,5 +1,5 @@
 /* Perform type resolution on the various structures.
 /* Perform type resolution on the various structures.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
    Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
@@ -4313,7 +4313,7 @@ check_host_association (gfc_expr *e)
   if (gfc_current_ns->parent
        && old_sym->ns != gfc_current_ns)
     {
   if (gfc_current_ns->parent
        && old_sym->ns != gfc_current_ns)
     {
-      gfc_find_symbol (old_sym->name, gfc_current_ns, 1, &sym);
+      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
       if (sym && old_sym != sym
              && sym->ts.type == old_sym->ts.type
              && sym->attr.flavor == FL_PROCEDURE
index 85c5288..cadac67 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-10  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/38765
+       * gfortran.dg/host_assoc_function_6.f90: New test.
+
 2009-01-09  Joel Sherrill <joel.sherrill@oarcorp.com>
 
        * lib/target-supports.exp: Add method to determine if the effective
 2009-01-09  Joel Sherrill <joel.sherrill@oarcorp.com>
 
        * lib/target-supports.exp: Add method to determine if the effective
diff --git a/gcc/testsuite/gfortran.dg/host_assoc_function_6.f90 b/gcc/testsuite/gfortran.dg/host_assoc_function_6.f90
new file mode 100644 (file)
index 0000000..28cd7c8
--- /dev/null
@@ -0,0 +1,35 @@
+! { dg-do compile }
+! Tests the fix for PR38765 in which the use associated symbol
+! 'fun' was confused with the contained function in 'mod_b'
+! because the real name was being used instead of the 'use'
+! name..
+!
+! Contributed by Paul Thomas  <pault@gcc.gnu.org>
+! from a report by Marco Restelli.
+!
+module mod_a
+  implicit none
+  public :: fun
+  private
+contains
+  pure function fun(x) result(mu)
+    real, intent(in) :: x(:,:)
+    real :: mu(2,2,size(x,2))
+    mu = 2.0
+  end function fun
+end module mod_a
+
+module mod_b
+  use mod_a, only: &
+  a_fun => fun
+  implicit none
+  private
+contains
+  pure function fun(x) result(mu)
+    real, intent(in) :: x(:,:)
+    real :: mu(2,2,size(x,2))
+    mu = a_fun(x)
+  end function fun
+end module mod_b
+
+! { dg-final { cleanup-modules "mod_a mod_b" } }