------- Comment #5 from janus at gcc dot gnu dot org  2010-01-18 13:46 -------
(In reply to comment #3)
> Here is a simple patch for setting the parent component accessibility:
> [...]
> This is probably not enough, since the access. specification of the parent 
> type
> may come after the daughter type definition. But this already fixes the exmple
> in comment #2.

This version should be better:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c       (revision 155994)
+++ gcc/fortran/resolve.c       (working copy)
@@ -10494,6 +10494,12 @@ resolve_fl_derived (gfc_symbol *sym)
          && resolve_typespec_used (&c->ts, &c->loc, c->name) == FAILURE)
        return FAILURE;

+      /* If this type is an extension, set the accessibility of the parent
+        component.  */
+      if (super_type && c == sym->components
+         && strcmp (super_type->name, c->name) == 0)
+       c->attr.access = super_type->attr.access;
+
       /* If this type is an extension, see if this component has the same name
         as an inherited type-bound procedure.  */
       if (super_type


It sets the accessibility at resolution time and makes the following variant of
comment #2 work:

module mo
  implicit none
  type :: tt
    integer :: i = 1
  end type
  type, extends(tt) :: ttt
    real :: x = 2.0
  end type
  private :: tt
end module
program pr
  use mo
  implicit none
  type(ttt) :: obj
  print *,obj%tt%i
end program


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42545

Reply via email to