[flang-commits] [flang] [flang] Handle useless NAMELIST in interface block (PR #175214)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Jan 9 09:44:30 PST 2026
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/175214
NAMELIST has no useful purpose in an interface block, but it's allowed. Fix a crash due to our deferred handling of NAMELIST groups in the execution part (which doesn't exist in an interface block).
Fixes https://github.com/llvm/llvm-project/issues/175207.
>From 28e948f95441a6a26e70bd0d22536ff6c11dfb81 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Fri, 9 Jan 2026 09:41:25 -0800
Subject: [PATCH] [flang] Handle useless NAMELIST in interface block
NAMELIST has no useful purpose in an interface block, but
it's allowed. Fix a crash due to our deferred handling of
NAMELIST groups in the execution part (which doesn't exist in
an interface block).
Fixes https://github.com/llvm/llvm-project/issues/175207.
---
flang/lib/Semantics/resolve-names.cpp | 3 +++
flang/test/Semantics/bug175207.f90 | 10 ++++++++++
2 files changed, 13 insertions(+)
create mode 100644 flang/test/Semantics/bug175207.f90
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index ae251476ed591..148cc439efa88 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -9872,6 +9872,9 @@ void ResolveNamesVisitor::FinishSpecificationPart(
misparsedStmtFuncFound_ = false;
funcResultStack().CompleteFunctionResultType();
CheckImports();
+ if (inInterfaceBlock()) {
+ FinishNamelists(); // NAMELIST is useless in an interface, but allowed
+ }
for (auto &pair : currScope()) {
auto &symbol{*pair.second};
if (inInterfaceBlock()) {
diff --git a/flang/test/Semantics/bug175207.f90 b/flang/test/Semantics/bug175207.f90
new file mode 100644
index 0000000000000..63696dfac0b63
--- /dev/null
+++ b/flang/test/Semantics/bug175207.f90
@@ -0,0 +1,10 @@
+!RUN: %python %S/test_errors.py %s %flang_fc1
+interface
+ subroutine sub(x)
+ real x
+ namelist /useless/x ! ok, but don't crash
+ !ERROR: 'sub' is not a variable
+ namelist /bad/sub
+ end
+end interface
+end
More information about the flang-commits
mailing list