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

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


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

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.

>From 5cd1c2c90f8d51d893168e0c21cf05db1a057621 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Thu, 25 Dec 2025 12:07:05 -0800
Subject: [PATCH] [flang] No ENTRY in interfaces

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.
---
 flang/lib/Semantics/resolve-names.cpp | 8 +++++++-
 flang/test/Semantics/entry01.f90      | 4 ++++
 2 files changed, 11 insertions(+), 1 deletion(-)

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



More information about the flang-commits mailing list