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]

Fwd: [Patch, Fortran] PR 43199 - Handle class%component references when reading .mod files


Dear Tobias,

It is my intention to go through the OOP implementation routing out
references to
derived->components->.... in favour of using gfc_find_component
(derived, "$data", true, true) just so as not to weld in and bolt down
the representation of CLASS.  Could you do so here, please?

Thanks

Paul


---------- Forwarded message ----------
From: Janus Weil <jaydub66@googlemail.com>
Date: Sun, Feb 28, 2010 at 6:45 PM
Subject: Re: [Patch, Fortran] PR 43199 - Handle class%component
references  	when reading .mod files
To: Tobias Burnus <burnus@net-b.de>
Cc: gcc patches <gcc-patches@gcc.gnu.org>, gfortran <fortran@gcc.gnu.org>


Hi Tobias,

> this patch prevents an ICE when handling class%component in
> find_array_spec. The problem is that with CLASS(type) one has
> effectively another layer around type, i.e. kind of
>
> TYPE class.type
> ? type(type) :: data
>
> and one needs to accommodate for this extra layer. I think the attached
> patch correctly handles this.

Yes, in principle I think your patch is ok. For reasons of clarity I
would perhaps prefer the following version:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c ? ? ? (revision 157120)
+++ gcc/fortran/resolve.c ? ? ? (working copy)
@@ -4005,7 +4005,11 @@ find_array_spec (gfc_expr *e)

? ? ? case REF_COMPONENT:
? ? ? ?if (derived == NULL)
- ? ? ? ? derived = e->symtree->n.sym->ts.u.derived;
+ ? ? ? ? {
+ ? ? ? ? ? derived = e->symtree->n.sym->ts.u.derived;
+ ? ? ? ? ? if (derived->attr.is_class)
+ ? ? ? ? ? ? derived = derived->components->ts.u.derived;
+ ? ? ? ? }

? ? ? ?c = derived->components;


Moreover, a few lines further in find_array_spec, there is another
occasion where 'derived' is being set. Probably one also needs to
modify that one for CLASS components, maybe like this:

@@ -4015,6 +4019,8 @@ find_array_spec (gfc_expr *e)
? ? ? ? ? ? ?/* Track the sequence of component references. ?*/
? ? ? ? ? ? ?if (c->ts.type == BT_DERIVED)
? ? ? ? ? ? ? ?derived = c->ts.u.derived;
+ ? ? ? ? ? ? else if (c->ts.type == BT_CLASS)
+ ? ? ? ? ? ? ? derived = c->ts.u.derived->components->ts.u.derived;
? ? ? ? ? ? ?break;
? ? ? ? ? ?}

I haven't tried creating a test case which fails without this addition
(but maybe it would be good to include one in the patch).


> PS: I marked the test as "dg-do compile" but one can also use "run";
> what do you prefer?

dg-do compile is fine with me.

Cheers,
Janus



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy


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