This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] PR 37254/39850


Hi all,

here is a small follow-up patch to my recently committed fix for
PR39850, where I forgot to apply implicit typing for function actual
arguments.
The patch also fixes the old PR37254 (especially comments #1 and #3,
both similar to PR39850), which was left with an ICE after my previous
commit.

Regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2009-06-22  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/37254
	PR fortran/39850
	* interface.c (compare_parameter): Set implicit type for function
	actual arguments with BT_UNKNOWN.


2009-06-22  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/37254
	PR fortran/39850
	* gfortran.dg/interface_30.f90: Modified error message.
	* gfortran.dg/proc_decl_22.f90: New.
Index: gcc/testsuite/gfortran.dg/interface_30.f90
===================================================================
--- gcc/testsuite/gfortran.dg/interface_30.f90	(revision 148778)
+++ gcc/testsuite/gfortran.dg/interface_30.f90	(working copy)
@@ -15,9 +15,9 @@ program test
   call sub1(func1)
   call sub2(func2)
   call sub1(func3)
-  call sub2(func3)  ! { dg-error "Type mismatch in argument" }
+  call sub2(func3)  ! { dg-error "is not a subroutine" }
   call sub2(func4)
-  call sub1(func4)  ! { dg-error "Interface mismatch in dummy procedure" }
+  call sub1(func4)  ! { dg-error "is not a function" }
 contains
   subroutine sub1(a1)
     interface
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c	(revision 148778)
+++ gcc/fortran/interface.c	(working copy)
@@ -1407,9 +1407,14 @@ compare_parameter (gfc_symbol *formal, g
 	}
 
       if (formal->attr.function && !act_sym->attr.function)
-	gfc_add_function (&act_sym->attr, act_sym->name, &act_sym->declared_at);
-
-      if (formal->attr.subroutine && !act_sym->attr.subroutine)
+	{
+	  gfc_add_function (&act_sym->attr, act_sym->name,
+	  &act_sym->declared_at);
+	  if (act_sym->ts.type == BT_UNKNOWN
+	      && gfc_set_default_type (act_sym, 1, act_sym->ns) == FAILURE)
+	    return 0;
+	}
+      else if (formal->attr.subroutine && !act_sym->attr.subroutine)
 	gfc_add_subroutine (&act_sym->attr, act_sym->name,
 			    &act_sym->declared_at);
 
! { dg-do compile }
!
! PR 37254: Reject valid PROCEDURE statement with implicit interface
!
! Original test case by Dominique d'Humieres <dominiq@lps.ens.fr>
! Modified by Janus Weil <janus@gcc.gnu.org>

  real function proc3( arg1 )
     integer :: arg1
     proc3 = arg1+7
  end function proc3

program myProg
  PROCEDURE () :: proc3
  call proc4( proc3 )

contains

  subroutine proc4( arg1 )
     PROCEDURE(real) :: arg1
     print*, 'the func: ', arg1(0)
  end subroutine proc4

end program myProg


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