[flang-commits] [flang] [flang] Omit parent components for references to bindings (PR #84836)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Mar 11 14:34:04 PDT 2024


https://github.com/klausler created https://github.com/llvm/llvm-project/pull/84836

https://github.com/llvm/llvm-project/pull/78593 changed expression semantics to always include the names of parent components that were necessary to access an inherited component.  This turns out to have broken calls to inherited NOPASS procedure bindings. Update the patch to omit explicit parent components when accessing bindings, while retaining them for component accesses (including procedure components).

>From cf99e5858057afaad366eade7b043997430f6e4b Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 11 Mar 2024 14:30:15 -0700
Subject: [PATCH] [flang] Omit parent components for references to bindings

https://github.com/llvm/llvm-project/pull/78593 changed expression
semantics to always include the names of parent components that
were necessary to access an inherited component.  This turns out
to have broken calls to inherited NOPASS procedure bindings.
Update the patch to omit explicit parent components when accessing
bindings, while retaining them for component accesses (including
procedure components).
---
 flang/lib/Semantics/expression.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 54bfe0f2e1563d..167eb36962f129 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -1299,7 +1299,8 @@ static NamedEntity IgnoreAnySubscripts(Designator<SomeDerived> &&designator) {
       std::move(designator.u));
 }
 
-// Components of parent derived types are explicitly represented as such.
+// Components, but not bindings, of parent derived types are explicitly
+// represented as such.
 std::optional<Component> ExpressionAnalyzer::CreateComponent(DataRef &&base,
     const Symbol &component, const semantics::Scope &scope,
     bool C919bAlreadyEnforced) {
@@ -1307,7 +1308,8 @@ std::optional<Component> ExpressionAnalyzer::CreateComponent(DataRef &&base,
       base.Rank() > 0) { // C919b
     Say("An allocatable or pointer component reference must be applied to a scalar base"_err_en_US);
   }
-  if (&component.owner() == &scope) {
+  if (&component.owner() == &scope ||
+      component.has<semantics::ProcBindingDetails>()) {
     return Component{std::move(base), component};
   }
   if (const Symbol *typeSymbol{scope.GetSymbol()}) {



More information about the flang-commits mailing list