[Patch, Fortran, OOP] PR 44541: wrong code for polymorphic variable with INTENT(OUT)/Alloc w/ MOLD

Tobias Burnus burnus@net-b.de
Wed Sep 1 16:25:00 GMT 2010


  On 09/01/2010 11:41 AM, Janus Weil wrote:
> this patch implements the polymorphic default initialization of CLASS
> variables, which can happen in two situations:
> 1) polymorphic dummy with INTENT(OUT)
> 2) ALLOCATE(x, MOLD=y) where x and y are polymorphic.
>
> The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?

The patch looks fine; however, I was stumbling over:

+  if (sym->ts.type == BT_CLASS&&  sym->attr.referenced
+&&  sym->ns == gfc_current_ns
+&&  sym->attr.dummy&&  sym->attr.intent == INTENT_OUT)
+    apply_default_init (sym);


Namely, I was stumbling over the "attr.referenced" part. I think that's 
wrong. I can initialize a variable using:
     subroutine intent_out(x)
       class(t), intent(out) :: x
       ! print *, x%a
     end subroutine
no need to uncomment the "print" line. (Tried with modifying the test 
case - and indeed it fails with an abort).

OK with fixing that part - and including it additionally in the 
class_dummy_1.f03 test case (or in an extra test case).**

Tobias

> 2010-09-01  Janus Weil<janus@gcc.gnu.org>
>
> 	PR fortran/44541
> 	* class.c (gfc_find_derived_vtab): Add component '$def_init'.
> 	* resolve.c (resolve_allocate_expr): Defer handling of default
> 	initialization to 'gfc_trans_allocate'.
> 	(apply_default_init,resolve_symbol): Handle polymorphic dummies.
> 	(resolve_fl_derived): Suppress error messages for vtypes.
> 	* trans-stmt.c (gfc_trans_allocate): Handle initialization via
> 	polymorphic MOLD expression.
> 	* trans-expr.c (gfc_trans_class_init_assign): Now only used for
> 	dummy initialization.
>
>
> 2010-09-01  Janus Weil<janus@gcc.gnu.org>
>
> 	PR fortran/44541
> 	* gfortran.dg/allocate_alloc_opt_10.f90: Extended.
> 	* gfortran.dg/class_dummy_1.f03: New.



More information about the Gcc-patches mailing list