This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran] PR 41580 Add compile-time simplification for Same_Type_As and Extends_Type_Of
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Fri, 7 Jan 2011 14:03:53 +0100
- Subject: Re: [Patch, Fortran] PR 41580 Add compile-time simplification for Same_Type_As and Extends_Type_Of
- References: <4D27066B.2070103@net-b.de>
Hi Tobias,
> This patch adds support for Same_Type_As and Extends_Type_Of; the patch is
> relatively straight forward, except that after gfc_resolve_* the simplify
> functions are called again - thus one needs to exit early otherwise the
> BT_DERIVED (as the vtab is internally represented) is simplified to .FALSE.
>
> Build and regtested on x86-64-linux.
> OK for the trunk? -- If so, which one: 4.6 or 4.7?
I think in principle your patch is ok, and I would like to see it in 4.6.
Some comments:
1) I don't particularly like the following part:
@@ -240,6 +240,7 @@ gfc_build_class_symbol (gfc_typespec *ts,
symbol_attribute *attr,
}
c->attr.access = ACCESS_PRIVATE;
c->attr.pointer = 1;
+ c->attr.vtab = 1;
}
Up to now we are using the "vtab" attribute to indicate that a symbol
is a vtable entry for a particular type. Now here you use it to mark a
"_vptr" component of a class container, which is a different thing (it
usually *points* to a vtab), and I'm not sure if this mix-up could
create problems somehow.
If you want to check for a _vptr component, you could just check for
the name (I think I've also been doing this in a recent patch).
2) A very minor thing: I think "DONT_EXISTS" is not a very
grammatically correct name for a subroutine. Not that subroutine names
are required to be grammatically correct in any Fortran standard I
know of, but I just stumbled over it ;)
3) Could you expand a bit on why a BT_DERIVED would be simplified to
.false.? I don't quite get that part ...
Thanks for working on this!
Cheers,
Janus