[flang] Fix check for distinguishable operators/assignments
authorTim Keith <tkeith@nvidia.com>
Thu, 10 Sep 2020 14:22:52 +0000 (07:22 -0700)
committerTim Keith <tkeith@nvidia.com>
Thu, 10 Sep 2020 14:22:55 +0000 (07:22 -0700)
commit82edd428f1856ff386716b4f836194252458d001
treea34dbc8ac6e89d7324e9713226fab5a62944faff
parent4e413e16216d0c94ada2171f3c59e0a85f4fa4b6
[flang] Fix check for distinguishable operators/assignments

Change how generic operators and assignments are checked for
distinguishable procedures. Because of how they are invoked, available
type-bound generics and normal generics all have to be considered
together. This is different from how generic names are checked.

Move common part of checking into DistinguishabilityHelper so that it
can be used in both cases after the appropriate procedures have been
added.

Cache result of Procedure::Characterize(Symbol) in a map in
CheckHelper so that we don't have to worry about passing the
characterized Procedures around or the cost of recomputing them.

Add MakeOpName() to construct names for defined operators and assignment
for using in error messages. This eliminates the need for different
messages in those cases.

When the procedures for a defined operator or assignment are undistinguishable,
include the type name in the error message, otherwise it may be ambiguous.

Add missing check that procedures for defined operators are functions
and that their dummy arguments are INTENT(IN) or VALUE.

Differential Revision: https://reviews.llvm.org/D87341
14 files changed:
flang/include/flang/Semantics/tools.h
flang/lib/Evaluate/tools.cpp
flang/lib/Semantics/check-declarations.cpp
flang/lib/Semantics/resolve-names-utils.cpp
flang/lib/Semantics/resolve-names-utils.h
flang/lib/Semantics/resolve-names.cpp
flang/lib/Semantics/tools.cpp
flang/test/Semantics/resolve11.f90
flang/test/Semantics/resolve13.f90
flang/test/Semantics/resolve15.f90
flang/test/Semantics/resolve25.f90
flang/test/Semantics/resolve53.f90
flang/test/Semantics/resolve96.f90 [new file with mode: 0644]
flang/test/Semantics/test_errors.sh