diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-06-20 22:16:29 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-06-20 22:16:29 +0000 |
commit | 2cf4aa79c811c5c658c0a66bcb70278c8fbe89ce (patch) | |
tree | 2d0d87e8c5501c2538a3175b681001dd2d5edcf4 /gcc/fortran/decl.c | |
parent | c35f57c5bd2b7d3fcf04f7bb8134db43c5b31059 (diff) | |
download | gcc-2cf4aa79c811c5c658c0a66bcb70278c8fbe89ce.tar.gz |
re PR fortran/77632 ([F08] Pointer initialisation does not quite work with arrays)
2019-06-20 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77632
* /decl.c (variable_decl): Mark a variable that is a target in pointer
initialization when in PROGRAM, MODULE, or SUBMODULE scope with an
implicit save.
2019-06-20 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77632
* gfortran.dg/pr77632_1.f90: New test.
From-SVN: r272526
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 7fcb60ab7ab..f5517f0d75f 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -2779,6 +2779,16 @@ variable_decl (int elem) m = match_pointer_init (&initializer, 0); if (m != MATCH_YES) goto cleanup; + + /* The target of a pointer initialization must have the SAVE + attribute. A variable in PROGRAM, MODULE, or SUBMODULE scope + is implicit SAVEd. Explicitly, set the SAVE_IMPLICIT value. */ + if (initializer->expr_type == EXPR_VARIABLE + && initializer->symtree->n.sym->attr.save == SAVE_NONE + && (gfc_current_state () == COMP_PROGRAM + || gfc_current_state () == COMP_MODULE + || gfc_current_state () == COMP_SUBMODULE)) + initializer->symtree->n.sym->attr.save = SAVE_IMPLICIT; } else if (gfc_match_char ('=') == MATCH_YES) { |