[flang] Handle SAVE attribute and statement
authorTim Keith <tkeith@nvidia.com>
Thu, 21 Feb 2019 01:45:39 +0000 (17:45 -0800)
committerTim Keith <tkeith@nvidia.com>
Thu, 21 Feb 2019 16:59:38 +0000 (08:59 -0800)
commitb6eb981caac11cbefe717e8f82c32b24cf8e163d
treebb1d956ae3fde2b783344d5cd7c0f5675dd52fbf
parentefd7bdb030364222947c2bf5dddea6482987f001
[flang] Handle SAVE attribute and statement

As with COMMON blocks, we can't completely check SAVE statements and
attributes until the end of the specification part when we have seen
full declarations of entities. So when SAVE is specified, add it to one
of the two sets in `saveInfo_`. At the end of the specification part,
check that those entities can have SAVE applied and set it if it is
not already implicitly set (e.g. due to being in a module). Also apply
the "global" SAVE if present (i.e. setting it on every applicable
entity).

Add `IsDummy()` and `IsFuncResult()` to `Symbol` to simplify some of
the checks. Also detect attempts to put a function result in a common
block.

Original-commit: flang-compiler/f18@af19c02baca371ffff13722fa17792a1f26e7bcd
Reviewed-on: https://github.com/flang-compiler/f18/pull/298
flang/lib/semantics/resolve-names.cc
flang/lib/semantics/symbol.cc
flang/lib/semantics/symbol.h
flang/test/semantics/CMakeLists.txt
flang/test/semantics/resolve42.f90
flang/test/semantics/resolve45.f90 [new file with mode: 0644]