[flang] Resolve extended intrinsic operators
authorTim Keith <tkeith@nvidia.com>
Sat, 2 Nov 2019 16:56:46 +0000 (09:56 -0700)
committerTim Keith <tkeith@nvidia.com>
Mon, 4 Nov 2019 18:47:43 +0000 (10:47 -0800)
commitdce7f0aca07a17cf2ded5a04c642aa94597cb95e
tree0cad776b713dfe96ce06bdadea023ae7c799255d
parent41aa3bf7a4bca781152a3ef82992b44673ae83a1
[flang] Resolve extended intrinsic operators

Enhance `ArgumentAnalyzer` to do most of the work for this.
For each kind of operator that might have a user-defined form we follow
this process:
- analyze the arguments
- if the types and shapes match the intrinsic operator do the usual
  processing
- otherwise attempt to interpret it as a user-defined operator with
  `TryDefinedOp`

When we fail to resolve an operator, produce different errors depending
on whether there is a user-defined operator available or not.
If there is, report that neither user-defined nor intrinsic operator
worked. If there is not, describe the rules for the intrinsic operator.
In either case, include the type(s) of the operand(s).

Most of the uses of `ArgumentAnalyzer` are in helper functions that
apply to classes of operators.
For consistency, rename `BinaryOperationHelper` to `NumericBinaryOperator`
and `LogicalHelper` to `LogicalBinaryHelper` and introduce `NumericUnaryHelper`
for unary `+` and `-`.  `.NOT.` and `//` are not implemented in helpers.

Replace `success_` with `fatalErrors_` in `ArgumentAnalyzer` for
consistency with `ExpressionAnalyzer`.

Add `NumericOperator` and `LogicalOperator` enums to `Fortran.h` to go
with `RelationalOperator`. Add `AddFortran` functions to each to convert
to a Fortran source string. `RelationalOperator` also has `AllFortranNames`
because there are multiple names for each operator. This replaces
`LogicalOperator` in `expression.h` and the string representation of
the operators in `formatting.cc`.

Original-commit: flang-compiler/f18@3bb9d664e86c931a67b3e78859d2108e53d23f80
Reviewed-on: https://github.com/flang-compiler/f18/pull/807
flang/lib/common/CMakeLists.txt
flang/lib/common/Fortran.cc [new file with mode: 0644]
flang/lib/common/Fortran.h
flang/lib/evaluate/expression.h
flang/lib/evaluate/formatting.cc
flang/lib/evaluate/tools.cc
flang/lib/semantics/expression.cc
flang/lib/semantics/expression.h
flang/test/semantics/CMakeLists.txt
flang/test/semantics/modfile33.f90 [new file with mode: 0644]
flang/test/semantics/resolve63.f90 [new file with mode: 0644]