Commit 2cf4aa79 by Steven G. Kargl

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
parent c35f57c5
2019-06-20 Steven G. Kargl <kargl@gcc.gnu.org> 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/86587 PR fortran/86587
* symbol.c (verify_bind_c_derived_type): Remove erroneous error * symbol.c (verify_bind_c_derived_type): Remove erroneous error
checking for BIND(C) and PRIVATE attributes. checking for BIND(C) and PRIVATE attributes.
......
...@@ -2779,6 +2779,16 @@ variable_decl (int elem) ...@@ -2779,6 +2779,16 @@ variable_decl (int elem)
m = match_pointer_init (&initializer, 0); m = match_pointer_init (&initializer, 0);
if (m != MATCH_YES) if (m != MATCH_YES)
goto cleanup; 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) else if (gfc_match_char ('=') == MATCH_YES)
{ {
......
2019-06-20 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77632
* gfortran.dg/pr77632_1.f90: New test.
2019-06-20 Marek Polacek <polacek@redhat.com> 2019-06-20 Marek Polacek <polacek@redhat.com>
PR c++/68265 PR c++/68265
......
! { dg-do run }
program foo
implicit none
real, target :: a
real, pointer :: b => a
if (associated(b, a) .eqv. .false.) stop 1
end program foo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment