[multiple changes]
2006-02-03 Steven G. Kargl <kargls@comcast.net> Paul Thomas <pault@gcc.gnu.org> * resolve.c (resolve_symbol): Default initialization of derived type component reguires the SAVE attribute. 2006-02-03 Steven G. Kargl <kargls@comcast.net> * gfortran.dg/char_result_11.f90: Add SAVE. * gfortran.dg/der_pointer_4.f90: Ditto. * gfortran.dg/default_initialization.f90: New test. From-SVN: r110554
This commit is contained in:
parent
c57bf6210b
commit
219fa8c3bd
@ -1,3 +1,9 @@
|
|||||||
|
2006-02-03 Steven G. Kargl <kargls@comcast>
|
||||||
|
Paul Thomas <pault@gcc.gnu.org>
|
||||||
|
|
||||||
|
* resolve.c (resolve_symbol): Default initialization of derived type
|
||||||
|
component reguires the SAVE attribute.
|
||||||
|
|
||||||
2006-02-02 Steven G. Kargl <kargls@comcast>
|
2006-02-02 Steven G. Kargl <kargls@comcast>
|
||||||
|
|
||||||
PR fortran/24958
|
PR fortran/24958
|
||||||
|
@ -4511,11 +4511,12 @@ resolve_symbol (gfc_symbol * sym)
|
|||||||
int formal_ns_save, check_constant, mp_flag;
|
int formal_ns_save, check_constant, mp_flag;
|
||||||
int i, flag;
|
int i, flag;
|
||||||
gfc_namelist *nl;
|
gfc_namelist *nl;
|
||||||
gfc_symtree * symtree;
|
gfc_symtree *symtree;
|
||||||
gfc_symtree * this_symtree;
|
gfc_symtree *this_symtree;
|
||||||
gfc_namespace * ns;
|
gfc_namespace *ns;
|
||||||
gfc_component * c;
|
gfc_component *c;
|
||||||
gfc_formal_arglist * arg;
|
gfc_formal_arglist *arg;
|
||||||
|
gfc_expr *constructor_expr;
|
||||||
|
|
||||||
if (sym->attr.flavor == FL_UNKNOWN)
|
if (sym->attr.flavor == FL_UNKNOWN)
|
||||||
{
|
{
|
||||||
@ -4857,6 +4858,26 @@ resolve_symbol (gfc_symbol * sym)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 4th constraint in section 11.3: "If an object of a type for which
|
||||||
|
component-initialization is specified (R429) appears in the
|
||||||
|
specification-part of a module and does not have the ALLOCATABLE
|
||||||
|
or POINTER attribute, the object shall have the SAVE attribute." */
|
||||||
|
|
||||||
|
if (sym->ts.type == BT_DERIVED && !(sym->value || flag))
|
||||||
|
constructor_expr = gfc_default_initializer (&sym->ts);
|
||||||
|
|
||||||
|
if (sym->ns->proc_name
|
||||||
|
&& sym->ns->proc_name->attr.flavor == FL_MODULE
|
||||||
|
&& constructor_expr
|
||||||
|
&& !sym->ns->save_all && !sym->attr.save
|
||||||
|
&& !sym->attr.pointer && !sym->attr.allocatable)
|
||||||
|
{
|
||||||
|
gfc_error("Object '%s' at %L must have the SAVE attribute %s",
|
||||||
|
sym->name, &sym->declared_at,
|
||||||
|
"for default initialization of a component");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Assign default initializer. */
|
/* Assign default initializer. */
|
||||||
if (sym->ts.type == BT_DERIVED && !(sym->value || flag)
|
if (sym->ts.type == BT_DERIVED && !(sym->value || flag)
|
||||||
&& !sym->attr.pointer)
|
&& !sym->attr.pointer)
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2006-02-03 Steven G. Kargl <kargls@comcast.net>
|
||||||
|
|
||||||
|
* gfortran.dg/char_result_11.f90: Add SAVE.
|
||||||
|
* gfortran.dg/der_pointer_4.f90: Ditto.
|
||||||
|
* gfortran.dg/default_initialization.f90: New test.
|
||||||
|
|
||||||
2006-02-03 Jeff Law <law@redhat.com>
|
2006-02-03 Jeff Law <law@redhat.com>
|
||||||
|
|
||||||
* lib/gcc-dg.exp (cleanup-rtl-dump): Fix dump file regexp to
|
* lib/gcc-dg.exp (cleanup-rtl-dump): Fix dump file regexp to
|
||||||
|
@ -16,7 +16,7 @@ module cutils
|
|||||||
integer(1) :: n1 = 3, n2 = 3, n3 = 3, n4 = 3, n6 = 3, n8 = 3
|
integer(1) :: n1 = 3, n2 = 3, n3 = 3, n4 = 3, n6 = 3, n8 = 3
|
||||||
character(10) :: s = "abcdefghij"
|
character(10) :: s = "abcdefghij"
|
||||||
integer :: x(4) = (/ 30, 40, 50, 60 /)
|
integer :: x(4) = (/ 30, 40, 50, 60 /)
|
||||||
type(t) :: tt1(5), tt2(5)
|
type(t), save :: tt1(5), tt2(5)
|
||||||
|
|
||||||
public :: IntToChar1, IntToChar2, IntToChar3, IntToChar4, IntToChar5, &
|
public :: IntToChar1, IntToChar2, IntToChar3, IntToChar4, IntToChar5, &
|
||||||
IntToChar6, IntToChar7, IntToChar8
|
IntToChar6, IntToChar7, IntToChar8
|
||||||
|
18
gcc/testsuite/gfortran.dg/default_initialization.f90
Normal file
18
gcc/testsuite/gfortran.dg/default_initialization.f90
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
!
|
||||||
|
! { dg-do compile }
|
||||||
|
! PR 20845
|
||||||
|
!
|
||||||
|
! In ISO/IEC 1539-1:1997(E), 4th constraint in section 11.3:
|
||||||
|
!
|
||||||
|
! If an object of a type for which component-initialization is specified
|
||||||
|
! (R429) appears in the specification-part of a module and does not have
|
||||||
|
! the ALLOCATABLE or POINTER attribute, the object shall have the SAVE
|
||||||
|
! attribute.
|
||||||
|
!
|
||||||
|
module bad
|
||||||
|
implicit none
|
||||||
|
type default_initialization
|
||||||
|
integer :: x = 42
|
||||||
|
end type default_initialization
|
||||||
|
type (default_initialization) t ! { dg-error "default initialization" }
|
||||||
|
end module bad
|
@ -7,5 +7,5 @@ module crash
|
|||||||
integer :: i = 0
|
integer :: i = 0
|
||||||
type (foo), pointer :: next
|
type (foo), pointer :: next
|
||||||
end type foo
|
end type foo
|
||||||
type (foo) :: bar
|
type (foo), save :: bar
|
||||||
end module crash
|
end module crash
|
||||||
|
Loading…
Reference in New Issue
Block a user