[flang] Parenthesize RHS arguments to defined assignments (bug #62599)
authorPeter Klausler <pklausler@nvidia.com>
Wed, 10 May 2023 23:18:47 +0000 (16:18 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Tue, 16 May 2023 17:29:56 +0000 (10:29 -0700)
commit01e22dfb104e7ab4737e512d4e1bbc609962b13e
tree38b11632870b10837039a70b8fc39f62fc146cfd
parent7c1f279328451e7c17cc16e9142adf11293f32c7
[flang] Parenthesize RHS arguments to defined assignments (bug #62599)

The right-hand sides of assignment statements are always expressions,
never variables.  When an assignment statement is converted into a call
to a defined assignment subroutine, and the actual argument being associated
with the second dummy argument is a variable, and the dummy argument does
not have the VALUE attribute, wrap it with parentheses so that lowering
will pass it by means of a temporary.

Fixes https://github.com/llvm/llvm-project/issues/62599.

Differential Revision: https://reviews.llvm.org/D150331
flang/lib/Semantics/expression.cpp
flang/test/Lower/array-user-def-assignments.f90
flang/test/Lower/user-defined-operators.f90
flang/test/Semantics/defined-ops.f90