[flang-commits] [PATCH] D150814: [flang] Don't complain about dummy subroutine under IMPLICIT NONE
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed May 17 13:36:17 PDT 2023
klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a project: All.
klausler requested review of this revision.
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
https://reviews.llvm.org/D150814
Files:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/implicit13.f90
Index: flang/test/Semantics/implicit13.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/implicit13.f90
@@ -0,0 +1,9 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+subroutine implicit_none(func, sub, obj)
+ implicit none
+ call sub ! ok
+ !ERROR: No explicit type declared for 'func'
+ print *, func()
+ !ERROR: No explicit type declared for 'obj'
+ print *, obj
+end
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -2424,6 +2424,13 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150814.523164.patch
Type: text/x-patch
Size: 1182 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230517/76f71771/attachment-0001.bin>
More information about the flang-commits
mailing list