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
Verify that checksums are correct when reading a module file.
Don't write a module file if its current contents are correct.
Don't make .mod files read-only. It doesn't do much to prevent
users from editing them, checksum verification will detect when
it happens, and having them read-only causes problems if you then
compile with another compiler (e.g. PGI).
Original-commit: flang-compiler/f18@21d82aef6e
Reviewed-on: https://github.com/flang-compiler/f18/pull/164
Tree-same-pre-rewrite: false
Symbols for submodules have `ModuleDetails` with `isSubmodule` set.
Scopes for submodules have `Module` kind and have a parent scope that
is also `Module` kind.
Scopes for modules now contain a mapping of submodule name to scope
so that we can find them without having to search the scope tree or
re-read their `.mod` file.
The module file for submodule `s` with ancestor module `m` is named `m-s.mod`.
The tree structure of scopes means module file writing is now recursive.
Similarly, reading the module file for a submodule may require reading
the module files of its parent and ancestor. `ResolveNames` now requires
the parent scope to be passed in -- it is not always the global scope.
`test_modfiles.sh` now handles an argument that is a filename glob so
that the test can involve multiple files. This allows `modfile09` to
test reading of `.mod` files for modules and submodules.
Original-commit: flang-compiler/f18@2e4424dbc8
Reviewed-on: https://github.com/flang-compiler/f18/pull/160
Tree-same-pre-rewrite: false