Closed tskeith closed 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.
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 typet
.The conversion happens in expression analysis so that where the accessibity must be checked. So move
CheckAccessibleComponent
totools.h
so that it can be shared byresolve-names.cpp
andexpression.cpp
.Also check that an access-spec can only appear in a module.