Skip to content

Commit 6e0b0ec

Browse files
authored
[flang] Fix crash in Semantics (#148706)
Allow for renaming in USE association of Cray pointers. Fixes #148559.
1 parent 78b9128 commit 6e0b0ec

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

flang/lib/Semantics/tools.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ const Symbol &BypassGeneric(const Symbol &symbol) {
348348

349349
const Symbol &GetCrayPointer(const Symbol &crayPointee) {
350350
const Symbol *found{nullptr};
351-
for (const auto &[pointee, pointer] :
352-
crayPointee.GetUltimate().owner().crayPointers()) {
353-
if (pointee == crayPointee.name()) {
351+
const Symbol &ultimate{crayPointee.GetUltimate()};
352+
for (const auto &[pointee, pointer] : ultimate.owner().crayPointers()) {
353+
if (pointee == ultimate.name()) {
354354
found = &pointer.get();
355355
break;
356356
}

flang/test/Semantics/bug148559.f90

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
!RUN: %flang_fc1 -fsyntax-only %s
2+
!Regression test for crash in semantics on Cray pointers
3+
4+
module m
5+
pointer(ptr,pp)
6+
end module m
7+
8+
program main
9+
use m, only:renamea=>pp
10+
use m, only:pp
11+
print *, renamea
12+
end

0 commit comments

Comments
 (0)