[flang-commits] [PATCH] D130385: [flang] Clean up bogus semantic error on procedure pointer assignment
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Jul 22 12:20:07 PDT 2022
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
When a procedure pointer with no interface is associated with
an EXTERNAL name with no interface information, but it is later
inferred that the procedure pointer must be a subroutine because it
appears in a CALL statement, don't complain that the EXTERNAL name
is not also known to be a subroutine.
Subroutine vs. function errors are still caught in procedure pointer
assignment compatibility checking; this fix simply ensures that those
more nuanced tests are not overridded by the attribute set equality test.
Also, leave in some code for dumping the differing attributes in legitimate
error cases that was added in the coures of debugging the specific problem.
https://reviews.llvm.org/D130385
Files:
flang/lib/Evaluate/characteristics.cpp
flang/test/Semantics/assign03.f90
Index: flang/test/Semantics/assign03.f90
===================================================================
--- flang/test/Semantics/assign03.f90
+++ flang/test/Semantics/assign03.f90
@@ -100,7 +100,7 @@
!ERROR: Procedure pointer 'p_impure' associated with incompatible procedure designator 'f_elemental2': incompatible dummy argument #1: incompatible dummy data object attributes
p_impure => f_elemental2
- !ERROR: Procedure pointer 'sp_impure' associated with incompatible procedure designator 's_impure2': incompatible procedure attributes
+ !ERROR: Procedure pointer 'sp_impure' associated with incompatible procedure designator 's_impure2': incompatible procedure attributes: BindC
sp_impure => s_impure2
!ERROR: Procedure pointer 'sp_impure' associated with incompatible procedure designator 's_pure2': incompatible dummy argument #1: incompatible dummy data object intents
sp_impure => s_pure2
@@ -292,5 +292,11 @@
integer, parameter :: i = rank(b)
end subroutine
-
+ subroutine s13
+ external :: s_external
+ procedure(), pointer :: ptr
+ !Ok - don't emit an error about incompatible Subroutine attribute
+ ptr => s_external
+ call ptr
+ end subroutine
end
Index: flang/lib/Evaluate/characteristics.cpp
===================================================================
--- flang/lib/Evaluate/characteristics.cpp
+++ flang/lib/Evaluate/characteristics.cpp
@@ -949,9 +949,16 @@
if (!attrs.test(Attr::Elemental)) {
actualAttrs.reset(Attr::Elemental);
}
- if (attrs != actualAttrs) {
+ Attrs differences{attrs ^ actualAttrs};
+ differences.reset(Attr::Subroutine); // dealt with specifically later
+ if (!differences.empty()) {
if (whyNot) {
+ auto sep{": "s};
*whyNot = "incompatible procedure attributes";
+ differences.IterateOverMembers([&](Attr x) {
+ *whyNot += sep + EnumToString(x);
+ sep = ", ";
+ });
}
} else if ((IsFunction() && actual.IsSubroutine()) ||
(IsSubroutine() && actual.IsFunction())) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130385.446932.patch
Type: text/x-patch
Size: 2049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220722/7399b1b5/attachment.bin>
More information about the flang-commits
mailing list