Possible accepts-invalid in derived-type extension

Daniel Kraft d@domob.eu
Mon Aug 25 10:16:00 GMT 2008


Hi Paul,

while reading your type-extension code, I found you are using 
gfc_find_component to check if a extension type declares a component 
with the same name as an inherited one.  This routine, however, does 
only find *accessible* components in the type-hierarchy.  So the 
following is accepted:

MODULE mod1

   TYPE t1
     PRIVATE
     INTEGER :: foobar
   END TYPE t1

END MODULE mod1

MODULE mod2
   USE mod1

   TYPE, EXTENDS(t1) :: t2
     INTEGER :: foobar
   END TYPE t2

END MODULE mod2

If the PRIVATE is removed, it is an error.   A note in the draft 
standard (in 4.5.6.1 Inheritance) says:

"Inaccessible components and bindings of the parent type are also 
inherited, ..."

Doesn't this mean that the above should be illegal?  If that's the case, 
I think we could add an additional argument to gfc_find_component to 
disable access checking.

Cheers,
Daniel

-- 
Done:     Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go:    Hea-Kni-Mon-Pri-Ran-Rog-Tou



More information about the Fortran mailing list