[flang-commits] [flang] [flang] Insert NAMELIST variables into symbol table during Pre (PR #179599)
via flang-commits
flang-commits at lists.llvm.org
Tue Feb 3 18:57:49 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: John Otken (jotken)
<details>
<summary>Changes</summary>
Call ResolveName for each variable in a NAMELIST in Pre(). This generates errors for two requirements in section 8.9 of the fortran standard. Briefly, objects shall have their declared type specified by previous statements or implicit rules. If an object is typed by the implicit rules, any subsequent type statement shall confirm the implied type.
Update test resolve40 s5 so that subsequent type statement confirms namelist implied type.
Co-authored-by: John Otken john.otken@<!-- -->hpe.com
---
Full diff: https://github.com/llvm/llvm-project/pull/179599.diff
2 Files Affected:
- (modified) flang/lib/Semantics/resolve-names.cpp (+4)
- (modified) flang/test/Semantics/resolve40.f90 (+2-2)
``````````diff
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index db84cc40c4283..efada9d6b5767 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -7195,6 +7195,10 @@ bool DeclarationVisitor::Pre(const parser::NamelistStmt::Group &x) {
groupSymbol = &MakeSymbol(groupName, NamelistDetails{});
groupSymbol->ReplaceName(groupName.source);
}
+ // insert namelist variables into the symbol table
+ for (const auto &name : std::get<std::list<parser::Name>>(x.t)) {
+ ResolveName(name);
+ }
// Name resolution of group items is deferred to FinishNamelists()
// so that host association is handled correctly.
GetDeferredDeclarationState(true)->namelistGroups.emplace_back(&x);
diff --git a/flang/test/Semantics/resolve40.f90 b/flang/test/Semantics/resolve40.f90
index 16b825250695e..466d704e9a46a 100644
--- a/flang/test/Semantics/resolve40.f90
+++ b/flang/test/Semantics/resolve40.f90
@@ -39,8 +39,8 @@ subroutine s4b
end
subroutine s5
- namelist /nl/x
- integer x
+ namelist /nl/i
+ integer i
end
subroutine s6
``````````
</details>
https://github.com/llvm/llvm-project/pull/179599
More information about the flang-commits
mailing list