[flang] Handle useless NAMELIST in interface block (#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.
This commit is contained in:
Peter Klausler 2026-01-12 15:40:22 -08:00 committed by GitHub
parent 3fe94ab4d6
commit 3874c4541a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -9876,6 +9876,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()) {

View file

@ -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