[flang-commits] [flang] c32d545 - [flang] Don't complain about dummy subroutine under IMPLICIT NONE

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu May 18 14:03:45 PDT 2023


Author: Peter Klausler
Date: 2023-05-18T14:03:28-07:00
New Revision: c32d5458b50fded7151261aac3b326de94f4174c

URL: https://github.com/llvm/llvm-project/commit/c32d5458b50fded7151261aac3b326de94f4174c
DIFF: https://github.com/llvm/llvm-project/commit/c32d5458b50fded7151261aac3b326de94f4174c.diff

LOG: [flang] Don't complain about dummy subroutine under IMPLICIT NONE

The compiler emits a bogus 'No explicit type declared for...' error
when a dummy procedure turns out to be a subroutine (or at least not
a function or object) under control of IMPLICIT NONE.

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

Differential Revision: https://reviews.llvm.org/D150814

Added: 
    flang/test/Semantics/implicit13.f90

Modified: 
    flang/lib/Semantics/resolve-names.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 4a4841d5a936..430d1c3399fa 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -2428,6 +2428,13 @@ void ScopeHandler::ApplyImplicitRules(
   if (allowForwardReference && ImplicitlyTypeForwardRef(symbol)) {
     return;
   }
+  if (const auto *entity{symbol.detailsIf<EntityDetails>()};
+      entity && entity->isDummy()) {
+    // Dummy argument, no declaration or reference; if it turns
+    // out to be a subroutine, it's fine, and if it is a function
+    // or object, it'll be caught later.
+    return;
+  }
   if (!context().HasError(symbol)) {
     Say(symbol.name(), "No explicit type declared for '%s'"_err_en_US);
     context().SetError(symbol);

diff  --git a/flang/test/Semantics/implicit13.f90 b/flang/test/Semantics/implicit13.f90
new file mode 100644
index 000000000000..0258de74f3e0
--- /dev/null
+++ b/flang/test/Semantics/implicit13.f90
@@ -0,0 +1,9 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+!ERROR: No explicit type declared for 'func'
+!ERROR: No explicit type declared for 'obj'
+subroutine implicit_none(func, sub, obj)
+  implicit none
+  call sub ! ok
+  print *, func()
+  print *, obj
+end


        


More information about the flang-commits mailing list