[flang-commits] [flang] [flang] Catch untyped entities in interfaces with IMPLICIT NONE (PR #109018)
via flang-commits
flang-commits at lists.llvm.org
Tue Sep 17 10:28:55 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/109018.diff
2 Files Affected:
- (modified) flang/lib/Semantics/resolve-names.cpp (+3)
- (added) flang/test/Semantics/implicit16.f90 (+12)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/109018
More information about the flang-commits
mailing list