mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-24 19:56:05 +00:00

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.