This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] PR32760 Error defining subroutine named PRINT


Hi all,

This simple patch fixes this problem by avoiding gfc_add_flavor when the symbol has the ACCESS_PUBLIC or ACCESS_PRIVATE attributes.

I must give credit to Daniel for tracking down the approximate location of this bug which allowed me to hunt around some and find it.

Regression tested on x86-64-Gnu/Linux. Test case provided.

OK for trunk?

Regards,

Jerry

2007-07-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
	    Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/32760
	* primary.c (match_variable): Do not call gfc_add_flavor if symbol has
	attribute of ACCESS_PUBLIC or ACCESS_PRIVATE already marked.
Index: primary.c
===================================================================
--- primary.c	(revision 126968)
+++ primary.c	(working copy)
@@ -2452,6 +2452,9 @@ match_variable (gfc_expr **result, int e
       break;
 
     case FL_UNKNOWN:
+      if (sym->attr.access == ACCESS_PUBLIC
+	  || sym->attr.access == ACCESS_PRIVATE)
+	break;
       if (gfc_add_flavor (&sym->attr, FL_VARIABLE,
 			  sym->name, NULL) == FAILURE)
 	return MATCH_ERROR;
! { dg-do compile }
! PR32760 Error defining subroutine named PRINT
! Test case derived from original PR.

module gfcbug68
  implicit none
  private :: write

contains

  function foo (i)
    integer, intent(in)  :: i
    integer foo

    write (*,*) i
    call write(i)
    foo = i
  end function foo

  subroutine write (m)
    integer, intent(in) :: m
    print *, m*m*m
  end subroutine write

end module gfcbug68

program testit
  use gfcbug68
  integer :: i = 27
  integer :: k
  
  k = foo(i)
  print *, "in the main:", k
end program testit

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]