[flang-commits] [flang] [flang] Catch untyped entities in interfaces with IMPLICIT NONE (PR #109018)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Tue Sep 17 10:28:17 PDT 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/109018
The order of operations in name resolution wasn't converting named entities to objects by the time that they were subjected to the implicit typing rules in the case of interface blocks. This led to entities remaining untyped without error, leading to a crash in module file generation.
Fixes https://github.com/llvm/llvm-project/issues/108975.
>From 0e73fa264b32da8f57de4e02eaf67bd16b03af61 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Tue, 17 Sep 2024 10:24:33 -0700
Subject: [PATCH] [flang] Catch untyped entities in interfaces with IMPLICIT
NONE
The order of operations in name resolution wasn't converting
named entities to objects by the time that they were subjected
to the implicit typing rules in the case of interface blocks.
This led to entities remaining untyped without error, leading
to a crash in module file generation.
Fixes https://github.com/llvm/llvm-project/issues/108975.
---
flang/lib/Semantics/resolve-names.cpp | 3 +++
flang/test/Semantics/implicit16.f90 | 12 ++++++++++++
2 files changed, 15 insertions(+)
create mode 100644 flang/test/Semantics/implicit16.f90
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index b99f308e1c7fab..0430a02dc3fb1a 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -8738,6 +8738,9 @@ void ResolveNamesVisitor::FinishSpecificationPart(
CheckImports();
for (auto &pair : currScope()) {
auto &symbol{*pair.second};
+ if (inInterfaceBlock()) {
+ ConvertToObjectEntity(symbol);
+ }
if (NeedsExplicitType(symbol)) {
ApplyImplicitRules(symbol);
}
diff --git a/flang/test/Semantics/implicit16.f90 b/flang/test/Semantics/implicit16.f90
new file mode 100644
index 00000000000000..4a03e0c15747df
--- /dev/null
+++ b/flang/test/Semantics/implicit16.f90
@@ -0,0 +1,12 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+interface
+!ERROR: No explicit type declared for 'a'
+ subroutine s(a)
+ implicit none
+ end
+!ERROR: No explicit type declared for 'f'
+ function f()
+ implicit none
+ end
+end interface
+end
More information about the flang-commits
mailing list