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]

Re: [Patch, Fortran] ICE with PROCEDURE using a complicated interface (PR36322 & PR36275)


> I might be mistaken, but I think with yesterday's patch you were effectively
> doing the same: You copied all elements.

Ok, sure, you're right. I somehow assumed the ts member of gfc_symbol
would be a pointer, which of course it is not!

> Unless I overlooked something, the following is equivalent to your patch:
>
>         sym->ts = sym->ts.interface->ts;
>         sym->attr.function = ifc->attr.function;
>         sym->attr.subroutine = ifc->attr.subroutine;
>         copy_formal_args (sym, ifc);
>
> and much more readable.

I agree that it's much more elegant. But in this form it's not 100%
equivalent. The little difference is that in your version the
sym->ts.interface will be lost after the assignment. I'm not sure if
it matters, since the link to the interface is probably not needed any
more after all the attributes have been copied. Just to be on the safe
side, the attached patch maintains the pointer to the interface. If
you think that it's not needed we can also leave it out.

> The question is whether one needs to additionally
> copy the gfc_charlen instead of only assigning the pointer, i.e. sym->ts.cl
> = gfc_get_charlen (); ... (and now one could continue with cl->length,
> cl->next etc.)

Ok, I will try to implement this, assuming it is indeed necessary.
Cheers,
Janus
Index: gcc/testsuite/gfortran.dg/proc_decl_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/proc_decl_2.f90	(revision 136328)
+++ gcc/testsuite/gfortran.dg/proc_decl_2.f90	(working copy)
@@ -4,16 +4,27 @@
 
 module m
 
+  use ISO_C_BINDING
+
   abstract interface
     subroutine csub() bind(c)
     end subroutine csub
   end interface
 
+  integer, parameter :: ckind = C_FLOAT_COMPLEX
+  abstract interface
+    function stub() bind(C)
+      import ckind
+      complex(ckind) stub
+    end function
+  end interface
+
   procedure():: mp1
   procedure(real), private:: mp2
   procedure(mfun), public:: mp3
   procedure(csub), public, bind(c) :: c, d
   procedure(csub), public, bind(c, name="myB") :: b
+  procedure(stub), bind(C) :: e
 
 contains
 
@@ -32,6 +43,15 @@ contains
     procedure(a), optional :: b
   end subroutine bar
 
+  subroutine bar2(x)
+    abstract interface
+      character function abs_fun()
+      end function
+    end interface
+    procedure(abs_fun):: x
+  end subroutine
+
+
 end module
 
 
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 136328)
+++ gcc/fortran/resolve.c	(working copy)
@@ -7847,6 +7847,7 @@ resolve_symbol (gfc_symbol *sym)
   gfc_symtree *this_symtree;
   gfc_namespace *ns;
   gfc_component *c;
+  gfc_symbol *ifc;
 
   if (sym->attr.flavor == FL_UNKNOWN)
     {
@@ -7893,11 +7894,12 @@ resolve_symbol (gfc_symbol *sym)
       /* Get the attributes from the interface (now resolved).  */
       if (sym->ts.interface->attr.if_source || sym->ts.interface->attr.intrinsic)
 	{
-	  sym->ts.type = sym->ts.interface->ts.type;
-	  sym->ts.kind = sym->ts.interface->ts.kind;
-	  sym->attr.function = sym->ts.interface->attr.function;
-	  sym->attr.subroutine = sym->ts.interface->attr.subroutine;
-	  copy_formal_args (sym, sym->ts.interface);
+	  ifc = sym->ts.interface;
+	  sym->ts = ifc->ts;
+	  sym->ts.interface = ifc;
+	  sym->attr.function = ifc->attr.function;
+	  sym->attr.subroutine = ifc->attr.subroutine;
+	  copy_formal_args (sym, ifc);
 	}
       else if (sym->ts.interface->name[0] != '\0')
 	{

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