[flang-commits] [flang] 948d0b3 - [flang] Correct actual/dummy procedure compatibility for ALLOCATABLE/POINTER functions
    Peter Klausler via flang-commits 
    flang-commits at lists.llvm.org
       
    Mon May  9 17:09:41 PDT 2022
    
    
  
Author: Peter Klausler
Date: 2022-05-09T16:40:21-07:00
New Revision: 948d0b340b86b9f0ba79195bdd67451832727fbf
URL: https://github.com/llvm/llvm-project/commit/948d0b340b86b9f0ba79195bdd67451832727fbf
DIFF: https://github.com/llvm/llvm-project/commit/948d0b340b86b9f0ba79195bdd67451832727fbf.diff
LOG: [flang] Correct actual/dummy procedure compatibility for ALLOCATABLE/POINTER functions
Functions returning ALLOCATABLE or POINTER arrays have descriptor inquiries in
their results' shape expressions that won't compare equal.  These functions
need only be checked for compatible ranks (& of course other characteristics).
Differential Revision: https://reviews.llvm.org/D125123
Added: 
    
Modified: 
    flang/lib/Evaluate/characteristics.cpp
Removed: 
    
################################################################################
diff  --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index cac34df644b4..95bc5f132703 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -788,7 +788,10 @@ bool FunctionResult::IsCompatibleWith(const FunctionResult &actual) const {
     return false;
   } else if (const auto *ifaceTypeShape{std::get_if<TypeAndShape>(&u)}) {
     if (const auto *actualTypeShape{std::get_if<TypeAndShape>(&actual.u)}) {
-      if (ifaceTypeShape->shape() != actualTypeShape->shape()) {
+      if (ifaceTypeShape->Rank() != actualTypeShape->Rank()) {
+        return false;
+      } else if (!attrs.test(Attr::Allocatable) && !attrs.test(Attr::Pointer) &&
+          ifaceTypeShape->shape() != actualTypeShape->shape()) {
         return false;
       } else {
         return ifaceTypeShape->type().IsTkCompatibleWith(
        
    
    
More information about the flang-commits
mailing list