[flang] Name resolution for defined operators
authorTim Keith <tkeith@nvidia.com>
Mon, 18 Mar 2019 18:48:02 +0000 (11:48 -0700)
committerTim Keith <tkeith@nvidia.com>
Mon, 18 Mar 2019 18:48:02 +0000 (11:48 -0700)
commit3ec5e102e2fe30d25a0ad61af898cc46330a13e1
tree05ced47d3fcda06fc8a9c5f33659223c40629af0
parent6092f4c7b128361146b482b2fb46cda807fb83df
[flang] Name resolution for defined operators

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@3081f694e21dbcaef2554198a682c9af57f2e185
Reviewed-on: https://github.com/flang-compiler/f18/pull/338
21 files changed:
flang/lib/parser/grammar.h
flang/lib/parser/parse-tree.h
flang/lib/parser/token-parsers.h
flang/lib/semantics/CMakeLists.txt
flang/lib/semantics/mod-file.cc
flang/lib/semantics/resolve-names-utils.cc [new file with mode: 0644]
flang/lib/semantics/resolve-names-utils.h [new file with mode: 0644]
flang/lib/semantics/resolve-names.cc
flang/lib/semantics/semantics.cc
flang/lib/semantics/semantics.h
flang/lib/semantics/symbol.cc
flang/lib/semantics/symbol.h
flang/test/semantics/CMakeLists.txt
flang/test/semantics/modfile07.f90
flang/test/semantics/modfile14.f90
flang/test/semantics/resolve11.f90
flang/test/semantics/resolve13.f90
flang/test/semantics/resolve15.f90
flang/test/semantics/resolve25.f90
flang/test/semantics/resolve47.f90 [new file with mode: 0644]
flang/tools/f18/f18.cc