public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR33233 - Parent and contained procedure: Wrongly treated as generic procedures
@ 2007-10-12 17:09 Paul Richard Thomas
  2007-10-12 18:52 ` Tobias Burnus
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Richard Thomas @ 2007-10-12 17:09 UTC (permalink / raw)
  To: fortran, gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 1096 bytes --]

:ADDPATCH fortran:

When I fixed the "50th anniversary bug", I missed completely another
underlying bug.  So much so that I checked for the incorrect behaviour
in the testcase host_assoc_function_1.f90!

This patch uses the same mechanism to fixup incorrectly host
associated symbols, where, in the meantime, a valid function symbol
has been generated.  It does this by doing the check even for singly
contained namespaces and starting the search for the new, function
symbol in the current namespace.

Bootstrapped and regtested on x86_ia64/FC5 and checked with tonto-2.3
- OK for trunk?

Cheers

Paul

2007-10-12  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/33233
	* resolve.c (check_host_association): Check singly contained
	namespaces and start search for symbol in current namespace.

2007-10-12  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/33233
	* gfortran.dg/host_assoc_function_1.f90: Correct references.
	* gfortran.dg/host_assoc_function_3.f90: New test.


-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

[-- Attachment #2: submit.diff --]
[-- Type: application/octet-stream, Size: 2651 bytes --]

Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c	(revision 129235)
--- gcc/fortran/resolve.c	(working copy)
*************** check_host_association (gfc_expr *e)
*** 3989,3999 ****
      return retval;
  
    if (gfc_current_ns->parent
- 	&& gfc_current_ns->parent->parent
  	&& old_sym->ns != gfc_current_ns)
      {
!       gfc_find_symbol (old_sym->name, gfc_current_ns->parent, 1, &sym);
!       if (sym && old_sym != sym && sym->attr.flavor == FL_PROCEDURE)
  	{
  	  temp_locus = gfc_current_locus;
  	  gfc_current_locus = e->where;
--- 3989,4000 ----
      return retval;
  
    if (gfc_current_ns->parent
  	&& old_sym->ns != gfc_current_ns)
      {
!       gfc_find_symbol (old_sym->name, gfc_current_ns, 1, &sym);
!       if (sym && old_sym != sym
! 	      && sym->attr.flavor == FL_PROCEDURE
! 	      && sym->attr.contained)
  	{
  	  temp_locus = gfc_current_locus;
  	  gfc_current_locus = e->where;
Index: gcc/testsuite/gfortran.dg/host_assoc_function_1.f90
===================================================================
*** gcc/testsuite/gfortran.dg/host_assoc_function_1.f90	(revision 129235)
--- gcc/testsuite/gfortran.dg/host_assoc_function_1.f90	(working copy)
*************** MODULE m
*** 19,26 ****
    end interface
  CONTAINS
    SUBROUTINE s
!     if (x(2) .ne. 2.5) call abort ()
!     if (z(3) .ne. real (3)**3) call abort ()
      CALL inner
    CONTAINS
      SUBROUTINE inner
--- 19,26 ----
    end interface
  CONTAINS
    SUBROUTINE s
!     if (x(2, 3) .ne. real (2)**3) call abort ()
!     if (z(3, 3) .ne. real (3)**3) call abort ()
      CALL inner
    CONTAINS
      SUBROUTINE inner
Index: gcc/testsuite/gfortran.dg/host_assoc_function_3.f90
===================================================================
*** gcc/testsuite/gfortran.dg/host_assoc_function_3.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/host_assoc_function_3.f90	(revision 0)
***************
*** 0 ****
--- 1,27 ----
+ ! { dg-do run }
+ ! Tests the fix for the bug PR33233, in which the reference to 'x'
+ ! in 'inner' wrongly host-associated with the variable 'x' rather
+ ! than the function.
+ !
+ ! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+ !
+ MODULE m
+   REAL :: x(3) = (/ 1.5, 2.5, 3.5 /)
+ CONTAINS
+   SUBROUTINE s
+     if (x(2) .eq. 2.5) call abort ()
+   CONTAINS
+     FUNCTION x(n, m)
+       integer, optional :: m
+       if (present(m)) then
+         x = REAL(n)**m
+       else
+         x = 0.0
+       end if
+     END FUNCTION
+   END SUBROUTINE s
+ END MODULE m
+   use m
+   call s
+ end
+ ! { dg-final { cleanup-modules "m" } }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, fortran] PR33233 - Parent and contained procedure: Wrongly  treated as generic procedures
  2007-10-12 17:09 [Patch, fortran] PR33233 - Parent and contained procedure: Wrongly treated as generic procedures Paul Richard Thomas
@ 2007-10-12 18:52 ` Tobias Burnus
  0 siblings, 0 replies; 2+ messages in thread
From: Tobias Burnus @ 2007-10-12 18:52 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: fortran, gcc-patches List

:REVIEWMAIL:

Paul Richard Thomas wrote:
> Bootstrapped and regtested on x86_ia64/FC5 and checked with tonto-2.3
> - OK for trunk?
>   
OK for the trunk and thanks for the patch.

Tobias

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-12 18:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-12 17:09 [Patch, fortran] PR33233 - Parent and contained procedure: Wrongly treated as generic procedures Paul Richard Thomas
2007-10-12 18:52 ` Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).