flang-compiler / f18

F18 is a front-end for Fortran intended to replace the existing front-end in the Flang compiler
229 stars 48 forks source link

Improve checking of structure constructor keywords #1046

Closed tskeith closed 4 years ago

tskeith commented 4 years ago

When a misparsed FunctionReference was converted to a StructureConstructor, the keywords were not checked for accessibility. For example, in t(i=1), i must not be a PRIVATE component of derived type t.

The conversion happens in expression analysis so that where the accessibity must be checked. So move CheckAccessibleComponent to tools.h so that it can be shared by resolve-names.cpp and expression.cpp.

Also check that an access-spec can only appear in a module.

tskeith commented 4 years ago

Private components can't be initialized in a structure constructor, keyword or not. See C7102.

(EDIT: I mean they can't be initialized in scopes where the component is not accessible; in the module where the type is defined, and its descendants, they're fine.)

Right, at Jean's suggestion my second commit implements that.