When a SeparateModuleSubprogram is encountered, check that there is a
corresponding declaration in the current module/submodule or an ancestor.
When it's the current program unit, special handling is required to
avoid trying to declare it again.
Module subprograms with the `MODULE` prefix are handled similarly.
The `hasModulePrefix` flag is passed in to `BeginSubprogram` to
distinguish this case.
Extract common part of `Post(SubroutineStmt)` and `Post(FunctionStmt)` into
`PostSubprogramStmt`. Add code there to ensure that separate module
procedures do not have `EXTERNAL` set. This requires a fix to `ModFileWriter`
to correctly decide when a subprogram is declared in an interface block.
Extract `WalkSubprogramPart` into a separate function. It walks the
internal or module subprograms collecting their names. It is needed to
handle separate module subprograms.
Original-commit: flang-compiler/f18@339b65f251
Reviewed-on: https://github.com/flang-compiler/f18/pull/218
Tree-same-pre-rewrite: false
If we have `SUBMODULE(m:s1) s2` and `s1` is already in memory (i.e. does
not need to be read from the `m-s1.mod` file), we still need to record
the fact that the name is a reference to that module symbol.
Original-commit: flang-compiler/f18@4bb42ed6a4
Reviewed-on: https://github.com/flang-compiler/f18/pull/218
Tree-same-pre-rewrite: false
Processing a SUBMODULE can cause any number of scopes to be pushed on
the scope stack. We don't know how many to pop at the end, so add
`ClearScopes()` to reset the scope stack to its original state.
Original-commit: flang-compiler/f18@0be4cebd66
Reviewed-on: https://github.com/flang-compiler/f18/pull/218
Tree-same-pre-rewrite: false
`a(i)` is parsed as a function reference and needs to be converted to an
array element reference when `a` is an object entity. That determination
was wrong if the symbol for `a` was a symbol representing host-association
or use-association. In that case we need to get to the original symbol
by calling `GetUltimate()` on the symbol.
This was causing symbol09.f90 to get a compilation error because an
array element reference looked like a call to a non-pure function, which
is prohibited inside a DO CONCURRENT.
Original-commit: flang-compiler/f18@221e6c52c5
Reviewed-on: https://github.com/flang-compiler/f18/pull/216
FoldingContext is now part of SemanticsContext. It is created at the
beginning with a default-constructed CharBlock as the location in its
ContextualMessages.
Add PushLocation() to ContextualMessages to remember the previous source
location and set a new one. The old one is restored when the returned
object goes out of scope.
SemanticsContext is now the only state passed in to class ExprAnalyzer,
class Mutator, AnalyzeExpr(), AnalyzeExpressions().
Add Say() convenience functions for reporting errors to ExprAnalyzer.
Original-commit: flang-compiler/f18@70c499ffc4
Reviewed-on: https://github.com/flang-compiler/f18/pull/215
Tree-same-pre-rewrite: false
The new SemanticsContext holds the state of semantics whose lifetime
spans all of the compilations. It contains the scope tree (and so all
symbols), the intrinsics table, messages, and the state of options that
affect semantics (default kinds, search directories, etc.)
Original-commit: flang-compiler/f18@f04ceab81f
Reviewed-on: https://github.com/flang-compiler/f18/pull/215
Tree-same-pre-rewrite: false
Push a new scope for constructs and statements that require one
(DataStmt, DO CONCURRENT, ForallConstruct, ForallStmt -- there are more
to do). Currently we use the Block kind of scope because there is no
difference. Perhaps that kind should be renamed to Construct, though it
does apply to statements as well as constructs.
Add DeclareConstructEntity to create a construct or statement entity.
When the type is not specified it can come from the type of a symbol in
the enclosing scope with the same name. Change DeclareObjectEntity et al.
to return the symbol declared, for the benefit of DeclareConstructEntity.
Use DeclareConstructEntity for DO CONCURRENT index-name, LOCAL, and
LOCAL_INIT variables and the data-i-do-variable in DataImpliedDo
Names in SHARED locality spec need special handling: create a new kinds
of symbol with HostAssocDetails to represent the host-association of the
shared variables within the construct scope. That symbol gets the
LocalityShared flag without affecting the symbol in the outer scope.
HostAssoc symbols may be useful in other contexts, e.g. up-level
references to local variables.
Add parser::DoConstruct::IsDoConcurrent() because DO CONCURRENT loops
introduce a construct scope while other DO loops do not.
Move CanonicalizeDo to before name resolution so that name resolution
doesn't have to deal with labeled DO CONCURRENT loops.
Allow for type of index name to be specified in ConcurrentHeader.
Resolve the derived type name in an AllocateStmt, StructureConstructor
Original-commit: flang-compiler/f18@bc7b989136
Reviewed-on: https://github.com/flang-compiler/f18/pull/214
Change it so that the first time a symbol is referenced, its full
definition is emitted, prefixed by "DEF:", and subsequent references
are prefixed with "REF:".
This doesn't give exactly the same results as before but it is
sufficient for testing and is simpler and easier to maintain.
The expected results need to be tweaked accordingly.
Original-commit: flang-compiler/f18@27b5d082a8
Reviewed-on: https://github.com/flang-compiler/f18/pull/214
Tree-same-pre-rewrite: false