Handle BIND statement and PARAMETER statement. They are different from
other attribute-setting statements so some refactoring of
HandleAttributeStmt is required. And for PARAMETER, SetType needs to
report an error if the implicitly determined type is changed later. This
requires operator== on DeclTypeSpec.
Resolve names in allocate statements, pointer assignment statements,
substring expressions, and type parameter values.
Original-commit: flang-compiler/f18@79ad96b976
Reviewed-on: https://github.com/flang-compiler/f18/pull/177
We were trying to write only symbols that are part of the public API of
a module to the .mod file. The problem with that is that submodules need
access to the private symbols in their ancestor modules and submodules.
For now, just write out all of the symbols, private or otherwise.
We could be more precise by omitting some private symbols for modules
that don't have separate module procedures and so can't have submodules.
Also, the old implementation went into an infinite loop for recursive
derived types.
This makes CollectSymbols simpler, so have it do both the collecting and
sorting. Make it static so that the types don't have to be defined in
mod-file.h.
Original-commit: flang-compiler/f18@33a10d6238
Reviewed-on: https://github.com/flang-compiler/f18/pull/177
Tree-same-pre-rewrite: false
A symbol is created with EntityDetails if we don't know whether it is a
procedure or data object. At the end of the specification part, if we
don't know it's a procedure then it must be an object, so convert it
then. So after name resolution there should be no symbols with
EntityDetails.
Also, a couple of small fixes:
- need to visit sub-nodes of shape specs so that any names get resolved
- don't report an error for an array element mis-parsed as a call
Original-commit: flang-compiler/f18@0effecd225
Reviewed-on: https://github.com/flang-compiler/f18/pull/177
Tree-same-pre-rewrite: false
Arrays are now represented with ObjectEntityDetails, not EntityDetails.
So that's what we have to look for when rewriting function calls to
array element references.
Original-commit: flang-compiler/f18@841b37d94b
Reviewed-on: https://github.com/flang-compiler/f18/pull/177
Tree-same-pre-rewrite: false
Also eliminate `derivedTypeData_`. Information about derived types needed
during name resolution is in `derivedTypeInfo_` and the permanent record
is the symbol table.
Original-commit: flang-compiler/f18@789960bd95
Reviewed-on: https://github.com/flang-compiler/f18/pull/175
Tree-same-pre-rewrite: false
Track PRIVATE statement in derived type components and in procedure
bindings. These are recorded in derivedTypeInfo_ (along with the name
appearing in EXTENDS) and used to modify the accessibility attributes of
components and bindings. Also track SEQUENCE statement.
Detect erroneous PRIVATE in derived types that aren't in modules.
Detect incompatible SEQUENCE types.
Save EXTENDS symbol and SEQUENCE in DerivedTypeDetails and write them to
the .mod file.
Original-commit: flang-compiler/f18@f29d620714
Reviewed-on: https://github.com/flang-compiler/f18/pull/175
Tree-same-pre-rewrite: false
Add TypeParamDetails for symbols that represent type parameters.
Create such symbols when a type-param-def-stmt is encountered.
At the end of the derived-type-def, check the parameters named
in the type-param-name-list against those encountered in each
type-param-def-stmt.
Original-commit: flang-compiler/f18@c15247bb30
Reviewed-on: https://github.com/flang-compiler/f18/pull/173
Tree-same-pre-rewrite: false
Add new kinds of symbol details: ProcBindingDetails, FinalProcDetails.
and GenericBindingDetails. The last is not yet implemented.
Write them to the .mod file.
Recognize DEFERRED and NON_OVERRIDABLE attributes. Enforce C783.
Resolve CLASS(t) similarly to resolution of TYPE(t).
Original-commit: flang-compiler/f18@0c0a9ab79e
Reviewed-on: https://github.com/flang-compiler/f18/pull/173
Tree-same-pre-rewrite: false
Resolve names and do implicit typing in ArrayElement and LoopBounds.
Fix problem with creation of UseErrorDetails: when a conflict occurs,
record both the original USE and the new one.
Resolve the type name in TypeAttrSpec::Extends. Move CheckUseError to
DeclarationVisitor so that it can be used in ResolveDerivedType.
Report error on unresolved names. I.e. after name resolution, check each
parser::Name and verify we have a Symbol for it. This is on by default
now but it could be an option.
Original-commit: flang-compiler/f18@1c8cbc6e53
Reviewed-on: https://github.com/flang-compiler/f18/pull/173
Tree-same-pre-rewrite: false
A `BLOCK` statement opens a new scope. It is different from other scopes
in that implicitly typed entities are defined in the enclosing non-block
scope, not immediately in the block. This means that `IMPORT` statements
can cause them to be hidden.
Check that blocks can't have `IMPLICIT` statements in them. It is simpler
for the parser not to deal with the different between a
specification-part and a block-specification-part.
Change `ImplicitRules` to have a parent that is consulted when there isn't
an answer in the current one. For an interface body that does not happen
but for all other nested scopes it does. This parent link eliminates the
need for the `implicitRules_` stack. Make `isImplicitNoneType_` and
`isImplicitNoneExternal_` optional: not set means look in parent.
Fixesflang-compiler/f18#71.
Remove `CurrNonTypeScope()` and put the logic in `Symbol::FindSymbol`.
Original-commit: flang-compiler/f18@a153a2ee33
Reviewed-on: https://github.com/flang-compiler/f18/pull/169
Tree-same-pre-rewrite: false
`CurrScope()` is now a simple accessor with no logic, so rename to `currScope()`.
`PushScope()` doesn't need to return a `Scope&` and the other functions
with that name do not, so make it consistent.
Original-commit: flang-compiler/f18@c8c341be14
Reviewed-on: https://github.com/flang-compiler/f18/pull/167
Tree-same-pre-rewrite: false
Host association is done by search for symbols using `Scope::FindSymbol()`
which looks for the the name in the parent scope if the import rules
permit it.
Import statements are implemented using `importKind_` and `importNames_`
in class `Scope`. Most of the constraints are checked when the
`ImportStmt` is encountered. `CheckImports()` is called at the end of
the `SpecificationPart` to verify the names mentioned in the IMPORT
statement. That has to happen then so that we can detect if an imported
name is hidden by a declaration in the current scope.
Original-commit: flang-compiler/f18@0d50c8a8ba
Reviewed-on: https://github.com/flang-compiler/f18/pull/167
Tree-same-pre-rewrite: false
We don't need to manage a stack of scopes: each scope has a reference to
its parent, so popping the scope stack is equivalent to setting the
new current scope to the parent of the old current scope.
Original-commit: flang-compiler/f18@022aa7a7f9
Reviewed-on: https://github.com/flang-compiler/f18/pull/167
Tree-same-pre-rewrite: false