clang give a compilation error on resolve-names.cc because there are
two overloadings of Pre(ProcedureDeclarationStmt) available in
ResolveNamesVisitor. One is defined in DeclTypeSpecVisitor and the other
in DeclarationVisitor. They are both brought in to ResolveNamesVisitor
via `using` statements.
The one in DeclarationVisitor is the one that is supposed to be called.
The other should have been removed when this one was added. This is the
one that gcc chooses to call, so this doesn't change any behavior.
The same applies to the Post method as well.
Original-commit: flang-compiler/f18@872f8faf96
Reviewed-on: https://github.com/flang-compiler/f18/pull/100
Add Dump() routines based on operator<< for the type so that they are
easy to call from the debugger. Overload for both pointer and reference
types and for dumping to std::cerr or a specific ostream.
Original-commit: flang-compiler/f18@ec6676eff0
Reviewed-on: https://github.com/flang-compiler/f18/pull/99
Replace operator=(Symbol) and operator=(DeclTypeSpec) with set_symbol()
and set_type() to make it clearer. Eliminate the move constructor as it
is not needed. Make all but the accessor functions out-of-line.
Change HasExplicitType() to NeedsExplicitType(), reversing its sense.
HasExplicitType() returned true for symbols that didn't have or need an
explicit type, which was confusing.
Original-commit: flang-compiler/f18@ada13ac6a3
Reviewed-on: https://github.com/flang-compiler/f18/pull/97
Add ObjectEntityDetails and ProcEntityDetails to distinguish between an
entity from an object-decl and one from a proc-decl. When we don't know,
it stays as EntityDetails until it is resolved. DeclareEntity() in
DeclarationVisitor creates this kind of symbol.
Add flags to Symbol as a convenient place for boolean flags common to
many kinds of symbols. Use it to mark symbols known to be functions or
subroutines so that we can report errors when they are used incorrectly.
Improve handling of EXTERNAL statement.
Handle ProcDecl nodes and add symbols for them.
Partial processing of derived types. Data component declarations are
processed and added to the derived type. Define TypeBoundProc and
TypeBoundGeneric in type.h. Procedure components, type-bound procedures,
etc. are not handled yet and nothing is done with the derived type once
it is created. Eliminate DerivedTypeDefBuilder in favor of just setting
fields in derivedTypeData_.
Add GetDeclTypeSpec to go with BeginDeclTypeSpec and EndDeclTypeSpec, to
avoid directly access the private variable.
Add tests in resolve20.f90 for errors related to procedure declarations.
Add missing copyrights to other tests.
Original-commit: flang-compiler/f18@40e65c1465
Reviewed-on: https://github.com/flang-compiler/f18/pull/97
Tree-same-pre-rewrite: false
This handles the common case of an error message referring to
a name, and an attached message referring to another name.
For example, reporting an error where a name is already declared
and mentioning the previous declaration.
Original-commit: flang-compiler/f18@901b50dcf2
Reviewed-on: https://github.com/flang-compiler/f18/pull/97
Tree-same-pre-rewrite: false
When a generic or specific procedure is use-associated, make a copy of
it in the current scope (replacing the symbol that has UseDetails) so
that we can make changes to it. This permits a generic to be defined in
one module and extended with more specific procedures in another.
When a specific procedure has the same name as its generic, it can't be
stored directly in the scope because that is indexed by name and the
generic is already there. So instead we store the specific in the
GenericDetails of the generic symbol.
Enforce the rule that a generic and a procedure can only have the same
name if the procedure is one of the specifics of the generic.
Refactorings done is support of this change:
- Add FindSymbol() and EraseSymbol() as helpers to find or erase a
symbol in the current scope. Make use of FindSymbol() where appropriate.
- Add SayAlreadyDeclared() to report a common error.
Original-commit: flang-compiler/f18@be479b9887
Reviewed-on: https://github.com/flang-compiler/f18/pull/95
This is the result of running `f18 -fdebug-resolve-names` on a bunch of
Fortran source and fixing the resulting assertion errors and segmentation
faults.
Most of the problems were with encountering attributes, array specs, or
declaration type specs when we weren't prepared to handle them. Those
were fixed by adding calls to {Begin,End}DeclTypeSpec and {Begin,End}Decl
when encountering certain nodes, though the real work for those nodes is
still to be done.
Extract some common functionality into PostAttrSpec and CheckUseError.
Add missing XOR to GenericSpec.
Original-commit: flang-compiler/f18@3c0ff7ded4
Reviewed-on: https://github.com/flang-compiler/f18/pull/93
Tree-same-pre-rewrite: false