A symbol for a common block has `CommonBlockDetails` which contains
a list of the symbols that are in the common block.
The name of the symbol for the blank common block is the empty string.
That preserves the property that every symbol name is a substring of
the cooked source. We use the 0-length substring starting at the COMMON
statement so that when symbols are sorted by the location of the start
of the name it ends up in the right place.
Some of the checks on members of common blocks don't happen until the
end of the scope. They can't happen earlier because we don't necessarily
know the type and attributes.
Enhance `test_errors.sh` so that multiple errors can be expected for
a single line.
Original-commit: flang-compiler/f18@2c4ca6b5d3
Reviewed-on: https://github.com/flang-compiler/f18/pull/286
The grammar requires parsing the first common block in a common stmt
differently from the others: the '//' is optional for the blank common.
But once it's parsed, it is easier to work with if each is represented
as a `parser::CommonStmt::Block`. This is achieved by using the same
constructor for `CommonStmt` but then including the first block in
the list of blocks.
Original-commit: flang-compiler/f18@dd46afd6b5
Reviewed-on: https://github.com/flang-compiler/f18/pull/284
When an association selector is an expression, we get the type of the
associate-name from the type of the expression. If that is a derived
type, we were failing to get the derived type scope in copy of the
type that was made. That meant the component names were not resolved.
The fix is to copy the scope in the copy and move constructors of
`DerivedTypeSpec`. As a result, `DerivedTypeSpec::Instantiate` cannot
assume that the `scope_` is not set.
Original-commit: flang-compiler/f18@79eaa8c47f
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
Tree-same-pre-rewrite: false
When the kind parameter is a constant name, that name must be resolved.
Add `CheckIntrinsicKind` and `CheckIntrinsicSize` for common checking of
valid intrinsic kinds. Previous we had different forms of the error
message depending on the context ( "unsupported INTEGER(KIND=47)" and
"INTEGER(KIND=47) is not a supported type").
Report error for parameters without initialization where are they
declared (in `Post(EntityDecl)`) rather than where they are referenced
(in `AnalyzeExpr`).
Remove error message from `AnalyzeKindParam`: `AnalyzeExpr` will report
the error (e.g. not integer, not constant, etc.).
Remove "name was not resolved" error from `AnalyzeExpr`: it should be
reported by name resolution.
Original-commit: flang-compiler/f18@9b0a99ce66
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
Tree-same-pre-rewrite: false
Enhance `FindInTypeOrParents()` to also accept a `parser::Name` argument
and to resolve that name when the symbol is found. This causes binding
names in type-bound generic statements to be resolved. Move this process
to the beginning of the handling of such statements so that they are
resolve even if the generic spec is not and we return early.
Also resolve type parameter keywords in derived type specs
(e.g. `k` in `type(k=1) :: x`). That involves collecting and searching
the symbols of the `TypeParamDetails` to match the name with the symbol.
Original-commit: flang-compiler/f18@7387fb436d
Reviewed-on: https://github.com/flang-compiler/f18/pull/281
Tree-same-pre-rewrite: false
Handle variables in data statements differently from implied dos:
If a variable is first mentioned in a data statement, it is implicitly
declared in the current scope (and subsequent type declarations only
confirm the type).
In the implied do case, the only variables that can be implicitly
declared are the iteration variables. They must be created in the new
ImpliedDos scope. There must be one such scope for each data-stmt-object
because the variable name can be reused.
Resolve references to named constants, e.g. in complex-literal-constant
and data-stmt-value. This requires changing the handling of
named-constant-def as that is a definition, not a reference.
Original-commit: flang-compiler/f18@9952b56af0
Reviewed-on: https://github.com/flang-compiler/f18/pull/277
Tree-same-pre-rewrite: false
Namelist groups are represents by symbols with `NamelistDetails`.
Those contain a list of symbols representing the objects in the group.
References to namelist groups in io-control-spec are resolved.
In `.mod` files, namelist groups are written out at the end of the
module specification section. This is so that the declarations of the
objects in the namelist group appear before they are referenced.
Original-commit: flang-compiler/f18@8b70dbcac7
Reviewed-on: https://github.com/flang-compiler/f18/pull/277
Tree-same-pre-rewrite: false