813e48dc21
Add `SemanticsVisitor` as the visitor class to perform statement semantics checks. Its template parameters are "checker" classes that perform the checks. They have `Enter` and `Leave` functions that are called for the corresponding parse tree nodes (`Enter` before the children, `Leave` after). Unlike `Pre` and `Post` in visitors they cannot prevent the parse tree walker from visiting child nodes. Existing checks have been incorporated into this framework: - `ExprChecker` replaces `AnalyzeExpressions()` - `AssignmentChecker` replaces `AnalyzeAssignments()` - `DoConcurrentChecker` replaces `CheckDoConcurrentConstraints()` Adding a new checker requires: - defining the checker class: - with BaseChecker as virtual base class - constructible from `SemanticsContext` - with Enter/Leave functions for nodes of interest - add the checker class to the template parameters of `StatementSemantics` Because these checkers and also `ResolveNamesVisitor` require tracking the current statement source location, that has been moved into `SemanticsContext`. `ResolveNamesVisitor` and `SemanticsVisitor` update the location when `Statement` nodes are encountered, making it available for error messages. `AnalyzeKindSelector()` now has access to the current statement through the context and so no longer needs to have it passed in. Test `assign01.f90` was added to verify that `AssignmentChecker` is actually doing something. Original-commit: flang-compiler/f18@3a222c3673 Reviewed-on: https://github.com/flang-compiler/f18/pull/315 Tree-same-pre-rewrite: false |
||
---|---|---|
.. | ||
assignment.cc | ||
assignment.h | ||
attr.cc | ||
attr.h | ||
canonicalize-do.cc | ||
canonicalize-do.h | ||
check-do-concurrent.cc | ||
check-do-concurrent.h | ||
CMakeLists.txt | ||
dump-parse-tree.h | ||
expression.cc | ||
expression.h | ||
mod-file.cc | ||
mod-file.h | ||
resolve-labels.cc | ||
resolve-labels.h | ||
resolve-names.cc | ||
resolve-names.h | ||
rewrite-parse-tree.cc | ||
rewrite-parse-tree.h | ||
scope.cc | ||
scope.h | ||
semantics.cc | ||
semantics.h | ||
symbol.cc | ||
symbol.h | ||
tools.cc | ||
tools.h | ||
type.cc | ||
type.h | ||
unparse-with-symbols.cc | ||
unparse-with-symbols.h |