diff options
author | Peter Klausler <35819229+klausler@users.noreply.github.com> | 2024-06-03 11:58:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-03 11:58:18 -0700 |
commit | 68f4e46c432ea2f1f8d33c6dc9345f6e2afeec4a (patch) | |
tree | 3e1aa1b44a58c91e3829f4404cb400bac2a36113 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | e44cea597cd835af9cbbd154f812aea3151af18b (diff) | |
download | llvm-68f4e46c432ea2f1f8d33c6dc9345f6e2afeec4a.zip llvm-68f4e46c432ea2f1f8d33c6dc9345f6e2afeec4a.tar.gz llvm-68f4e46c432ea2f1f8d33c6dc9345f6e2afeec4a.tar.bz2 |
[flang] Adjust "doubled operator" expression extension (#93353)
Most Fortran compilers accept "doubled operators" as a language
extension. This is the use of a unary '+' or '-' operator that is not
the first unparenthesized operator in an expression, as in 'x*-y'.
This compiler has implemented this extension, but in a way that's
different from other compilers' behavior. I interpreted the unary
'+'/'-' as a unary operator in the sense of C/C++, giving it a higher
priority than any binary (dyadic) operator.
All other compilers with this extension, however, give a unary '+'/'-' a
lower precedence than exponentiation ('**'), a binary operator that
C/C++ lacks. And this interpretation makes more sense for Fortran,
anyway, where the standard conforming '-x**y' must mean '-(x**y)'
already.
This patch makes 'x*-y**z' parse as 'x*-(y**z)', not 'x*(-y)**z)', and
adds a test to ensure that it does.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions