Parse tree nodes have `source` fields that map the node back to
a range in the cooked input stream. These are used for names and
to locate error messages.
This change strips spaces from the beginning and end of those
source ranges before they are saved. This fixes two problems:
1. For a statement like this: `generic :: operator(+) => ...`,
the name of the symbol we want to create is "operator(+)" but
the parser was including the following space in the CharBlock
it captured.
2. Error messages referring to parts of expressions sometimes included
extra spaces in the source locations. For example:
```
t.f90:9:29: error: subscripts may be applied only to an object or component
integer, parameter :: b = a(1) + 1
^^^^^
t.f90:4:8: error: operands to LOGICAL operation must be LOGICAL
i = j .or. k
^^^^^^^
```
Original-commit: flang-compiler/f18@fa14297967
Reviewed-on: https://github.com/flang-compiler/f18/pull/343
Tree-same-pre-rewrite: false
Instead of tracking just genericName_ while in a generic interface
block or generic statement, now we immediately create a symbol for it.
A parser::Name isn't good enough because a defined-operator or
defined-io-generic-spec doesn't have a name.
Change the parse tree to add a source field to GenericSpec. Use these
as names for symbols for defined-operator and defined-io-generic-spec
(e.g. "operator(+)" or "read(formatted)").
Change the source for defined-op-name to include the dots so that they
can be distinguished from normal symbols with the same name (e.g. you
can have both ".foo." and "foo"). These symbols have names in the symbol
table like ".foo.", not "operator(.foo.)", because references to them
have that form.
Add GenericKind enum to GenericDetails and GenericBindingDetails.
This allows us to know a symbol is "assignment(=)", for example,
without having to do a string comparison.
Add GenericSpecInfo to handle analyzing the various kinds of
generic-spec and generating symbol names and GenericKind for them.
Add reference to LanguageFeatureControl to SemanticsContext so that
they can be checked during semantics. For this change, if
LogicalAbbreviations is enabled, report an error if the user tries
to define an operator named ".T." or ".F.".
Add resolve-name-utils.cc to hold utility functions and classes that
don't have to be in the ResolveNamesVisitor class hierarchy. The goal
is to reduce the size of resolve-names.cc where possible.
Original-commit: flang-compiler/f18@3081f694e2
Reviewed-on: https://github.com/flang-compiler/f18/pull/338
The parser can't distinguish `saved-entity -> object-name` from
`saved-entity -> proc-pointer-name`. So just use `kind` == `Entity`
for those cases. Name resolution will verify it is the right kind
of entity name.
Original-commit: flang-compiler/f18@69d7c0e025
Reviewed-on: https://github.com/flang-compiler/f18/pull/298
Tree-same-pre-rewrite: false
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
remove needless template<> on some function overloads
dodge bogus compiler warning from gcc 8.1.0 only
stricter typing of expressions in symbols
adjust modfile12.f90 expected test results
add Unwrap, massage folding a bit
Use Unwrap to simplify folding
Move KindSelector analysis into expression semantics
fix crash
checkpoint
updates to TypeParamInquiry
support of %KIND type parameter inquiry
equality testing for expressions
checkpoint during PDT implementation
reformat
checkpoint derived type instantiation
checkpoint
resolve merge
debugging failed tests
fix failing resolve37.f90 test
all existing tests pass
clean up all build warnings
fix bug
update copyright dates
fix copyright dates
address review comments
review comment
merge with master after peeling off changes
bugfixing new feature
fix warning from old g++s
tweaks after merging with latest head
more bugfixing
making modfile17.f90 test work
Make kinds into expressions in symbol table types
big refactor for deferring kinds in intrinsic types
modfile17.f90 test passes
clean up TODOs
Simplify types as stored in scopes
Test KIND parameter default init expressions, debug them
Update copyright dates
address comments
remove dead line
address comments
Original-commit: flang-compiler/f18@1f43d0a048
Reviewed-on: https://github.com/flang-compiler/f18/pull/260
Tree-same-pre-rewrite: false
Rework how `parser::Name` is resolved to contain a `Symbol`. so that
constants in types can be evaluated. For example:
```
integer, parameter :: k = 8
integer(k) :: i
```
The old approach of collecting the symbols at the end of name resolution
and filling in the `parser::Name` does not work because the type of `i`
needs to be set in the symbol table.
The symbol field in `parser::Name` is now mutable so that we can set it
during name resolution. `RewriteParseTree` no longer needs to do that
(it still warns about unresolved ones), so it does not need to collect
symbols and fill them in. Consequently, we can eliminate "occurrences"
from symbols -- we just need the name where each is first defined.
This requires a lot of refactoring in `resolve-names.cc` to pass around
`parser::Name` rather than `SourceName` so that we can resolve the
name to a symbol.
Fix some bugs where we stored `SourceName *` instead of `SourceName`
in the symbol table. The pointers were into the parse tree, so they
were only valid as long as the parse tree was around. The symbol
table needs to remain valid longer than that, so the names need to
be copied. `parser::Name` is not used in the symbol table.
Eliminate `GenericSpec`. Currently all we need to do is to resolve
the kinds of GenericSpec that contain names.
Add `ScopeName` kind of `MiscDetails` for when we need a symbol in
the scope to match the name of the scope. For example, `module m`
cannot contain a declaration of a new `m`. Subprograms need real
details because they can be called recursively.
Fix output of partially resolved modules where we know it is a submodule
but have not yet resolved the ancestor.
Original-commit: flang-compiler/f18@5c1a4b99d2
Reviewed-on: https://github.com/flang-compiler/f18/pull/238
Tree-same-pre-rewrite: false