aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-common.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-09-27 23:46:14 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2005-09-27 23:46:14 +0200
commit57f0d086d592e6c9bb44c330939b9dda63d24934 (patch)
treec3973b2ad4259e5ebeaafcea074d679fc6155edd /gcc/fortran/trans-common.c
parent93954fcc895e40418cecc5c0c1d35ef579ea204d (diff)
downloadgcc-57f0d086d592e6c9bb44c330939b9dda63d24934.zip
gcc-57f0d086d592e6c9bb44c330939b9dda63d24934.tar.gz
gcc-57f0d086d592e6c9bb44c330939b9dda63d24934.tar.bz2
re PR fortran/18518 (equivalenced variables are not saved)
PR fortran/18518 * trans-common.c (build_equiv_decl): Add IS_SAVED argument. If it is true, set TREE_STATIC on the decl. (create_common): If any symbol in equivalence has SAVE attribute, pass true as last argument to build_equiv_decl. * gfortran.fortran-torture/execute/save_2.f90: New decl. From-SVN: r104712
Diffstat (limited to 'gcc/fortran/trans-common.c')
-rw-r--r--gcc/fortran/trans-common.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index 039d86d..de47f90 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -268,7 +268,7 @@ build_field (segment_info *h, tree union_type, record_layout_info rli)
/* Get storage for local equivalence. */
static tree
-build_equiv_decl (tree union_type, bool is_init)
+build_equiv_decl (tree union_type, bool is_init, bool is_saved)
{
tree decl;
char name[15];
@@ -286,7 +286,8 @@ build_equiv_decl (tree union_type, bool is_init)
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
- if (!gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl)))
+ if (!gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl))
+ || is_saved)
TREE_STATIC (decl) = 1;
TREE_ADDRESSABLE (decl) = 1;
@@ -385,6 +386,7 @@ create_common (gfc_common_head *com, segment_info * head, bool saw_equiv)
record_layout_info rli;
tree decl;
bool is_init = false;
+ bool is_saved = false;
/* Declare the variables inside the common block.
If the current common block contains any equivalence object, then
@@ -410,13 +412,17 @@ create_common (gfc_common_head *com, segment_info * head, bool saw_equiv)
/* Has initial value. */
if (s->sym->value)
is_init = true;
+
+ /* Has SAVE attribute. */
+ if (s->sym->attr.save)
+ is_saved = true;
}
finish_record_layout (rli, true);
if (com)
decl = build_common_decl (com, union_type, is_init);
else
- decl = build_equiv_decl (union_type, is_init);
+ decl = build_equiv_decl (union_type, is_init, is_saved);
if (is_init)
{