Skip to content

[flang] Catch untyped entities in interfaces with IMPLICIT NONE #109018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

klausler
Copy link
Contributor

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 #108975.

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 llvm#108975.
@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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

@klausler klausler requested a review from clementval September 17, 2024 18:58
Copy link
Contributor

@clementval clementval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@psteinfeld psteinfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All builds and tests correctly and looks good.

@klausler klausler merged commit 1e19e1e into llvm:main Sep 18, 2024
11 checks passed
@klausler klausler deleted the bug108975 branch September 18, 2024 19:20
tmsri pushed a commit to tmsri/llvm-project that referenced this pull request Sep 19, 2024
…#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 llvm#108975.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[flang] Flang is unable to compile a module with an interface block for a external proceure
4 participants