[flang-commits] [flang] [flang] Fix crash on SMP with dummy procedure (PR #124663)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Tue Jan 28 10:53:27 PST 2025
https://github.com/klausler updated https://github.com/llvm/llvm-project/pull/124663
>From 1b079fa8e421eea97faa930771a99bdab011eb40 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 27 Jan 2025 16:47:27 -0800
Subject: [PATCH] [flang] Fix crash on SMP with dummy procedure
When a separate module procedure is defined with MODULE PROCEDURE,
the compiler crashes if there is a dummy procedure in the interface
defined with only a result type. This is due to the type already
having been defined on the ProcEntityDetails symbol as part of earlier
wholesale symbol duplication. Adjust the code to not define the
result type of the ProcEntityDetails if it is already present,
but to verify that it is the same type instead.
Fixes https://github.com/llvm/llvm-project/issues/124487.
---
flang/lib/Semantics/resolve-names-utils.cpp | 6 +++++-
flang/test/Semantics/bug124487.f90 | 14 ++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 flang/test/Semantics/bug124487.f90
diff --git a/flang/lib/Semantics/resolve-names-utils.cpp b/flang/lib/Semantics/resolve-names-utils.cpp
index a838d49c06104d..347f54e0640705 100644
--- a/flang/lib/Semantics/resolve-names-utils.cpp
+++ b/flang/lib/Semantics/resolve-names-utils.cpp
@@ -762,7 +762,11 @@ void SymbolMapper::MapSymbolExprs(Symbol &symbol) {
proc.set_procInterfaces(
*mappedSymbol, BypassGeneric(mappedSymbol->GetUltimate()));
} else if (const DeclTypeSpec * mappedType{MapType(proc.type())}) {
- proc.set_type(*mappedType);
+ if (proc.type()) {
+ CHECK(*proc.type() == *mappedType);
+ } else {
+ proc.set_type(*mappedType);
+ }
}
if (proc.init()) {
if (const Symbol * mapped{MapSymbol(*proc.init())}) {
diff --git a/flang/test/Semantics/bug124487.f90 b/flang/test/Semantics/bug124487.f90
new file mode 100644
index 00000000000000..b91757c3623670
--- /dev/null
+++ b/flang/test/Semantics/bug124487.f90
@@ -0,0 +1,14 @@
+!RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck --allow-empty %s
+!CHECK-NOT: error:
+module m
+ interface
+ module subroutine smp(x)
+ character, external :: x
+ end
+ end interface
+end
+submodule (m) sm
+ contains
+ module procedure smp ! crashes here
+ end
+end
More information about the flang-commits
mailing list