diff options
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 6 | ||||
-rw-r--r-- | gcc/fortran/symbol.c | 16 |
3 files changed, 19 insertions, 11 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b2741b1..d8e54e1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2010-01-19 Janus Weil <janus@gcc.gnu.org> + + PR fortran/42545 + * resolve.c (resolve_fl_derived): Set the accessibility of the parent + component for extended types. + * symbol.c (gfc_find_component): Remove a wrongly-worded error message + and take care of parent component accessibility. + 2010-01-17 Janus Weil <janus@gcc.gnu.org> PR fortran/42677 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 6bc5fde..8f32d1a 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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 diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index a5787de..e363c5e 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -1958,23 +1958,17 @@ gfc_find_component (gfc_symbol *sym, const char *name, else if (sym->attr.use_assoc && !noaccess) { - if (p->attr.access == ACCESS_PRIVATE) + bool is_parent_comp = sym->attr.extension && (p == sym->components); + if (p->attr.access == ACCESS_PRIVATE || + (p->attr.access != ACCESS_PUBLIC + && sym->component_access == ACCESS_PRIVATE + && !is_parent_comp)) { if (!silent) gfc_error ("Component '%s' at %C is a PRIVATE component of '%s'", name, sym->name); return NULL; } - - /* If there were components given and all components are private, error - out at this place. */ - if (p->attr.access != ACCESS_PUBLIC && sym->component_access == ACCESS_PRIVATE) - { - if (!silent) - gfc_error ("All components of '%s' are PRIVATE in structure" - " constructor at %C", sym->name); - return NULL; - } } return p; |