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

Tim Keith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 26 12:42:56 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2921d148e7b: [flang] SAVE statement should not apply to nested scoping units (authored by rikigigi, committed by tskeith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88279/new/

https://reviews.llvm.org/D88279

Files:
  flang/lib/Evaluate/tools.cpp
  flang/test/Semantics/save01.f90


Index: flang/test/Semantics/save01.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/save01.f90
@@ -0,0 +1,21 @@
+! RUN: %S/test_errors.sh %s %t %f18
+MODULE test
+SAVE
+CONTAINS
+PURE FUNCTION pf( )
+   IMPLICIT NONE
+   INTEGER :: pf
+   INTEGER :: mc
+   !OK: SAVE statement is not inherited by the function
+END FUNCTION
+
+PURE FUNCTION pf2( )
+   IMPLICIT NONE
+   SAVE
+   INTEGER :: pf2
+   !ERROR: A pure subprogram may not have a variable with the SAVE attribute
+   INTEGER :: mc
+END FUNCTION
+
+END MODULE
+
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.294515.patch
Type: text/x-patch
Size: 1118 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200926/d0d18923/attachment.bin>


More information about the llvm-commits mailing list