[PATCH] D82309: [flang] Fix bug checking SAVE attribute

Tim Keith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 22 09:07:40 PDT 2020


tskeith created this revision.
tskeith added reviewers: klausler, PeteSteinfeld.
tskeith 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.

We were treating a SAVE statement without an entity-list as if it applied to all
items in a scoping unit, but it only applies to the allowed ones (8.6.14(1)).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82309

Files:
  flang/lib/Semantics/check-declarations.cpp
  flang/test/Semantics/resolve45.f90


Index: flang/test/Semantics/resolve45.f90
===================================================================
--- flang/test/Semantics/resolve45.f90
+++ flang/test/Semantics/resolve45.f90
@@ -15,8 +15,15 @@
   !ERROR: SAVE attribute may not be applied to dummy argument 'x'
   complex, save :: x
   allocatable :: y
+  integer :: y
   !ERROR: SAVE attribute may not be applied to dummy argument 'y'
-  integer, save :: y
+  save :: y
+end
+
+! SAVE statement should not trigger the above errors
+function f2b(x, y)
+  real :: x, y
+  save
 end
 
 subroutine s3(x)
Index: flang/lib/Semantics/check-declarations.cpp
===================================================================
--- flang/lib/Semantics/check-declarations.cpp
+++ flang/lib/Semantics/check-declarations.cpp
@@ -284,7 +284,7 @@
           "A dummy argument may not have the SAVE attribute"_err_en_US);
     }
   } else if (IsFunctionResult(symbol)) {
-    if (IsSaved(symbol)) {
+    if (symbol.attrs().test(Attr::SAVE)) {
       messages_.Say(
           "A function result may not have the SAVE attribute"_err_en_US);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82309.272457.patch
Type: text/x-patch
Size: 1095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200622/7fb87171/attachment-0001.bin>


More information about the llvm-commits mailing list