[flang-commits] [flang] [flang] No ENTRY in interfaces (PR #173577)

via flang-commits flang-commits at lists.llvm.org
Thu Dec 25 12:13:53 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

The ISO Fortran standard syntactically allows an ENTRY statement in an interface body, but doesn't define what it would mean, and no other compiler accepts it.

Fixes https://github.com/llvm/llvm-project/issues/173523.

---
Full diff: https://github.com/llvm/llvm-project/pull/173577.diff


2 Files Affected:

- (modified) flang/lib/Semantics/resolve-names.cpp (+7-1) 
- (modified) flang/test/Semantics/entry01.f90 (+4) 


``````````diff
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 5cc887791048d..64b4031e86bcb 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -4871,7 +4871,13 @@ bool SubprogramVisitor::Pre(const parser::FunctionStmt &) {
   }
   return BeginAttrs();
 }
-bool SubprogramVisitor::Pre(const parser::EntryStmt &) { return BeginAttrs(); }
+bool SubprogramVisitor::Pre(const parser::EntryStmt &stmt) {
+  if (inInterfaceBlock()) {
+    Say(std::get<parser::Name>(stmt.t).source,
+        "An ENTRY statement may not appear in an interface body"_err_en_US);
+  }
+  return BeginAttrs();
+}
 
 void SubprogramVisitor::Post(const parser::FunctionStmt &stmt) {
   const auto &name{std::get<parser::Name>(stmt.t)};
diff --git a/flang/test/Semantics/entry01.f90 b/flang/test/Semantics/entry01.f90
index 765b18c2e81a8..7176be169643c 100644
--- a/flang/test/Semantics/entry01.f90
+++ b/flang/test/Semantics/entry01.f90
@@ -7,6 +7,10 @@ module m1
   interface
     module subroutine separate
     end subroutine
+    subroutine hasentry
+      !ERROR: An ENTRY statement may not appear in an interface body
+      entry ent
+    end subroutine
   end interface
  contains
   subroutine modproc

``````````

</details>


https://github.com/llvm/llvm-project/pull/173577


More information about the flang-commits mailing list