[flang-commits] [flang] 6e0b0ec - [flang] Fix crash in Semantics (#148706)

via flang-commits flang-commits at lists.llvm.org
Wed Jul 16 09:09:09 PDT 2025


Author: Peter Klausler
Date: 2025-07-16T09:09:05-07:00
New Revision: 6e0b0ec66ac8de046cc95080166e2012819f7d93

URL: https://github.com/llvm/llvm-project/commit/6e0b0ec66ac8de046cc95080166e2012819f7d93
DIFF: https://github.com/llvm/llvm-project/commit/6e0b0ec66ac8de046cc95080166e2012819f7d93.diff

LOG: [flang] Fix crash in Semantics (#148706)

Allow for renaming in USE association of Cray pointers.

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

Added: 
    flang/test/Semantics/bug148559.f90

Modified: 
    flang/lib/Semantics/tools.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 5e5b43f26c791..5a5b02e1ac3ce 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -348,9 +348,9 @@ const Symbol &BypassGeneric(const Symbol &symbol) {
 
 const Symbol &GetCrayPointer(const Symbol &crayPointee) {
   const Symbol *found{nullptr};
-  for (const auto &[pointee, pointer] :
-      crayPointee.GetUltimate().owner().crayPointers()) {
-    if (pointee == crayPointee.name()) {
+  const Symbol &ultimate{crayPointee.GetUltimate()};
+  for (const auto &[pointee, pointer] : ultimate.owner().crayPointers()) {
+    if (pointee == ultimate.name()) {
       found = &pointer.get();
       break;
     }

diff  --git a/flang/test/Semantics/bug148559.f90 b/flang/test/Semantics/bug148559.f90
new file mode 100644
index 0000000000000..d7b959ac8f191
--- /dev/null
+++ b/flang/test/Semantics/bug148559.f90
@@ -0,0 +1,12 @@
+!RUN: %flang_fc1 -fsyntax-only %s
+!Regression test for crash in semantics on Cray pointers
+
+module m
+  pointer(ptr,pp)
+end module m
+
+program main
+  use m, only:renamea=>pp
+  use m, only:pp
+  print *, renamea
+end


        


More information about the flang-commits mailing list