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] PR40451: [F03] procedure pointer assignment rejected


Hi all,

here is my patch for PR40451, where a PROCEDURE with explicit
interface erroneously got implicitly typed before the interface was
copied to the symbol. The fix is easy: Only do the implicit typing if
the symbol has no ts.interface.

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

Cheers,
Janus


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

	PR fortran/40451
	* resolve.c (resolve_contained_fntype): Prevent implicit typing for
	procedures with explicit interface.
	* symbol.c (gfc_check_function_type): Ditto.

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

	PR fortran/40451
	* gfortran.dg/proc_ptr_result_4.f90: New.
Index: gcc/fortran/symbol.c
===================================================================
--- gcc/fortran/symbol.c	(revision 148601)
+++ gcc/fortran/symbol.c	(working copy)
@@ -317,7 +317,7 @@ gfc_check_function_type (gfc_namespace *
   if (!proc->attr.contained || proc->result->attr.implicit_type)
     return;
 
-  if (proc->result->ts.type == BT_UNKNOWN)
+  if (proc->result->ts.type == BT_UNKNOWN && proc->result->ts.interface == NULL)
     {
       if (gfc_set_default_type (proc->result, 0, gfc_current_ns)
 		== SUCCESS)
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 148601)
+++ gcc/fortran/resolve.c	(working copy)
@@ -347,7 +347,7 @@ resolve_contained_fntype (gfc_symbol *sy
     return;
 
   /* Try to find out of what the return type is.  */
-  if (sym->result->ts.type == BT_UNKNOWN)
+  if (sym->result->ts.type == BT_UNKNOWN && sym->result->ts.interface == NULL)
     {
       t = gfc_set_default_type (sym->result, 0, ns);
 
! { dg-do compile }
!
! PR 40451: [F03] procedure pointer assignment rejected 
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>

contains

  function f()
    intrinsic :: sin
    procedure(sin), pointer :: f
    f => sin
  end function f

end


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