This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] ICE with PROCEDURE using a complicated interface (PR36322 & PR36275)
- From: "Janus Weil" <jaydub66 at googlemail dot com>
- To: "Tobias Burnus" <burnus at net-b dot de>
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 3 Jun 2008 23:27:15 +0200
- Subject: Re: [Patch, Fortran] ICE with PROCEDURE using a complicated interface (PR36322 & PR36275)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=WkOqnXpPQ3Qx0dqsb2fPYw9E725HfVVp8CP4w+kgu3s=; b=fB4rjlldlerXjjz6Q40T4/IIckpKsh2rZvYvywHgbQvOyiMu5icDbaGI29srPBETtUjtGm7GjIcTuOnXdrSV2/uIdGMoXUS86xGD9r+f6Vh47xobMiczXAUH/HL+t4ZUAdzAxJgQX+X+ITgUCB7/3J2FaZhkUGopJMZOfEPTWXM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=U6/KT917q63XIjNMWLbjv7JnilEwos3IZMqLyQ7+/IHD+gH+oKRXLk7w8gYVtPp8t+yq8d+JRR6OrxRe6gmBdXvnH4FvQ7ltLJwCjpPiiIPTrTJxIGBSPqUr5GOQeqUC4m8bD6pj+5yu3CFPE+9Ix1wHExupSFS7ExKxQ5XCXfA=
- References: <854832d40806031021y598db915kbb69742b0b396dd9@mail.gmail.com> <484589A7.70209@net-b.de>
> 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')
{