[Patch, Fortran] PR 40941: gfc_typespec: put derived, cl and interface into union
Janus Weil
janus@gcc.gnu.org
Thu Aug 13 08:58:00 GMT 2009
2009/8/3 Janus Weil <janus@gcc.gnu.org>:
> Hi all,
>
> this patch cleans up a FIXME item from gfortran.h. It is rather large,
> but almost completely mechanical. The central change is this one in
> the gfc_typespec structure:
>
> Index: gcc/fortran/gfortran.h
> ===================================================================
> --- gcc/fortran/gfortran.h (revision 150364)
> +++ gcc/fortran/gfortran.h (working copy)
> @@ -832,13 +832,19 @@ gfc_charlen;
>
> #define gfc_get_charlen() XCNEW (gfc_charlen)
>
> -/* Type specification structure. FIXME: derived and cl could be union??? */
> +/* Type specification structure. */
> typedef struct
> {
> bt type;
> int kind;
> - struct gfc_symbol *derived;
> - gfc_charlen *cl; /* For character types only. */
> +
> + union
> + {
> + struct gfc_symbol *derived; /* For derived types only. */
> + gfc_charlen *cl; /* For character types only. */
> + }
> + u;
> +
> struct gfc_symbol *interface; /* For PROCEDURE declarations. */
> int is_c_interop;
> int is_iso_c;
>
> For now I have only put 'derived' and 'cl' into the union. This has
> triggered a large amount of trivial mechanical changes, but also some
> non-mechanical ones (which were needed to fix testsuite regressions),
> most notably the ones in:
>
> * decl.c (build_struct)
> * symbol.c (gfc_get_default_type)
> * resolve.v (resolve_symbol, resolve_fl_derived, resolve_equivalence,
> resolve_equivalence_derived)
>
> I'm not quite sure if it would be possible to also put 'interface'
> into the union (will investigate). If yes, this could be done in a
> follow-up patch.
>
> The patch is regtested on x86_64-unknown-linux-gnu. I will write a
> ChangeLog soon (although I'm not looking forward to it).
>
> Ok for trunk?
Ping!
I know that this may not be the easiest patch to review, since it's
kind of huge. But at least it's mostly mechanical, and I listed the
few non-mechanical parts above, so it should be possible to review
just those and the general idea of the patch.
Or do people think this patch is a bad idea? After all it should
reduce gfortran's memory consumption a bit, since it shrinks the
gfc_typespec structure ...
Due to its size, I'm afraid the patch will be rotting rather fast. If
I don't get a review, maybe I could at least get an opinion ;)
Cheers,
Janus
More information about the Gcc-patches
mailing list