[PATCH] D88279: SAVE statement should not apply to nested scoping units

Riccardo Bertossa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 00:21:42 PDT 2020


rikigigi created this revision.
rikigigi added reviewers: sscalpone, schweitz, tskeith.
rikigigi added a project: Flang.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
rikigigi requested review of this revision.

SAVE statement, according to 8.6.14, must apply to the same scoping unit, that excludes nested scoping units. For example, if the SAVE statement is found in a MODULE, the functions contained in that module should not inherit the SAVE attribute. I think that the code was doing this, failing the following code:

  MODULE pippo
  SAVE
  
  CONTAINS
  PURE FUNCTION fft_stick_index( )
     IMPLICIT NONE
     INTEGER :: fft_stick_index
     INTEGER :: mc  !error: A pure subprogram may not have a variable with the SAVE attribute
  END FUNCTION
  
  END MODULE


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88279

Files:
  flang/lib/Evaluate/tools.cpp


Index: flang/lib/Evaluate/tools.cpp
===================================================================
--- flang/lib/Evaluate/tools.cpp
+++ flang/lib/Evaluate/tools.cpp
@@ -1004,12 +1004,8 @@
       return true;
     } else if (IsDummy(symbol) || IsFunctionResult(symbol)) {
       return false;
-    } else {
-      for (; !scope->IsGlobal(); scope = &scope->parent()) {
-        if (scope->hasSAVE()) {
-          return true;
-        }
-      }
+    } else if (scope->hasSAVE() ) {
+      return true;
     }
   }
   return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88279.294235.patch
Type: text/x-patch
Size: 536 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200925/6e1ffa12/attachment.bin>


More information about the llvm-commits mailing list