[flang] Fix crash on structure constructor as selector
authorpeter klausler <pklausler@nvidia.com>
Thu, 3 Jun 2021 00:21:41 +0000 (17:21 -0700)
committerpeter klausler <pklausler@nvidia.com>
Thu, 3 Jun 2021 21:48:30 +0000 (14:48 -0700)
commite712a92b8fe706c4a736748af324382850d1515c
treee615ab8acb93b68bd3a58e088d3b539655dd4cf3
parenta4b924a017dba3e5f891ef38e07a7a80da65a8b8
[flang] Fix crash on structure constructor as selector

In something like "ASSOCIATE(X=>T(1))", the "T(1)" is parsed
as a Variable because it looks like a function reference or
array reference; if it turns out to be a structure constructor,
which is something we can't know until we're able to attempt
generic interface resolution in semantics, the parse tree needs
to be fixed up by replacing the Variable with an Expr.

The compiler could already do this for putative function references
encapsulated as Exprs, so this patch moves some code around and
adds parser::Selector to the overloads of expression analysis.

Differential Revision: https://reviews.llvm.org/D103572
flang/include/flang/Semantics/expression.h
flang/lib/Semantics/expression.cpp
flang/lib/Semantics/resolve-names.cpp