[fortran-dev] constructor work, part I and II, updated

Daniel Franke franke.daniel@gmail.com
Fri Jan 1 19:18:00 GMT 2010


On Wednesday 30 December 2009 07:34:36 Daniel Franke wrote:
> As the initial patch and the update did not get a formal review yet, I
> continued to work on it. Here's the whole of (a), (b) and (c) in one big
> changeset. It bootstraps and regtests fine up to one regression where I'm
>  not sure it's a real regression or not a latent bug uncovered by the
>  changes (char_component_initializer_1.f90). Either way, I didn't manage
>  yet to get rid of it yet. There are also issues with this testcase in
>  trunk as well (see PR42526).

Please find an updated version of the patch attached.

There are four changes:
 1. Update decl.c (add_init_expr_to_sym) to use init as first value, as
    Tobias S. mentioned this may lead to problems otherwise. This now reads:

+               gfc_constructor_append_expr (&array->value.constructor,
+                                            n == 0
+                                               ? init
+                                               : gfc_copy_expr (init),
+                                            &init->where);
+

 2. removed a piece of junk code that was left over from reg-hunting
 3. fixed the last regresssion on char_component_initializer_1.f90
    The relevant section for both changes in decl.c (build_struct) now reads:

-             for (; ctor; ctor = ctor->next)
+             for ( ; ctor; ctor = gfc_constructor_next (ctor))
+               if (ctor->expr->expr_type == EXPR_CONSTANT)
                {
-                 if (ctor->expr->expr_type == EXPR_CONSTANT)
-                   gfc_set_constant_character_len (len, ctor->expr,
-                                                   has_ts ? -1 : first_len);
+                 gfc_set_constant_character_len (len, ctor->expr,
+                                                 has_ts ? -1 : first_len);
+                 ctor->expr->ts.u.cl->length = gfc_copy_expr (c->ts.u.cl-
>length);
                }

 4. Fixed an issue with data.f90 of the testsuite that crept in
    Here, the difference is the direction of the comparison:

-      if (mpz_get_si (c->offset) + mpz_get_si (c->repeat) > offset)
+      if (mpz_get_si (c->offset) + mpz_get_si (c->repeat) <= offset)


Thanks to Jerry for pointing out (2) and (4).


> What's left to do: merge array.c (gfc_get_array_element) and expr.c
> (find_array_element) into constructor.c (gfc_constructor_lookup). The first
>  is not easily removed as it implicitly expands arrays not expanded yet.
>  Jerry's patch might help there. Further, some simplifiers still iterate
>  over all elements (see ADVANCE macro in simplify.c), these simplifiers
>  need to be reimplemented for direct element access.

Another item: remove the 'repeat' member of 'struct gfc_constructor'. This 
should simplify the fix(es) for bugs related to DATA-statements.


Regression tested on i686-pc-linux-gnu. No more regressions but the OOP-
related ones on fortran-dev.


Cheers

	Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: constructor-4d.diff.gz
Type: application/x-gzip
Size: 25586 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20100101/97701415/attachment.bin>


More information about the Fortran mailing list