------- Comment #6 from burnus at gcc dot gnu dot org 2010-01-18 14:36 ------- (In reply to comment #5) > It sets the accessibility at resolution time and makes the following variant > of comment #2 work:
That variant works for me already with the trunk, i.e. it is not rejected which is (for me) the expected result. * * * As it took me a while to see whether the various examples are valid or not. (Comment 0 is quite unrelated as it about TBP vs. component accessibility while the rest is about accessibility of inherited components.) Fortran 2003 has in "4.5.6.1 Inheritance": "An extended type includes all of the type parameters, all of the components, and the nonoverridden (4.5.6.2) nonfinal procedure bindings of its parent type. These are said to be inherited by the extended type from the parent type. They retain all of the attributes that they had in the parent type. Additional type parameters, components, and procedure bindings may be declared in the derived-type definition of the extended type." "An extended type has a scalar, nonpointer, nonallocatable, parent component with the type and type parameters of the parent type. The name of this component is the parent type name. It has the accessibility of the parent type." "Note 4.51: Inaccessible components and bindings of the parent type are also inherited, but they remain inaccessible in the extended type. Inaccessible entities occur if the type being extended is accessed via use association and has a private entity." Thus the crucial part is: a) For components "they retain all of the attributes that they had in the parent type" -- thus the PRIVATE statement which only changes the default has no influence. b) For the parent type: If it is PRIVATE then also extended%parent%par_comp is only accessible in the module per "It has the accessibility of the parent type" in the second paragraph. But what about: extended%par_comp ? par_comp is PUBLIC while its TYPE is PRIVATE. Just from reading the standard, it looks valid. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42545