http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50410
--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-18
07:23:10 UTC ---
>From the standard:
"C568 (R536) A data-i-do-object or a variable that appears as a
data-stmt-object shall not be an object designator in which a
pointer appears other than as the entire rightmost part-ref."
"C567 (R536) A variable whose designator appears as a
data-stmt-object or a data-i-do-object shall not be a dummy
argument, accessed by use or host association, in a named
common block unless the DATA statement is in a block data
program unit, in blank common, a function name, a function
result name, an automatic object, or an allocatable variable."
To be fixed beyond the patch of attachment 25534
* ICE below (1) for init of DT with default init
* ICE below (2) with structure constructor, which initializes a pointer
(plus: test cases, revised error message wording)
* (3) Pointer init in DATA: Also "initial-data-target" is allowed
For the pointer init, see also PR 45290.
! =============== (1) =======================
module m
type t
integer :: a = 7
end type t
type t2
integer :: b
end type t2
end module m
use m
implicit type(t)(x), type(t2)(y)
! ICE in trans:
! Invalid as "nonpointer object has default initialization"
DATA x%a/8/
! OK:
!DATA y%b/5/
!type(t2) :: y = t2(7) ! { dg-error "initializer already appears in a DATA
statement" }
end
! ============= (2) =========================
module m
type t
integer :: a
integer, pointer :: bar
end type t
end module m
subroutine test()
use m
type(t) :: x ! = t(4, null()) ! OK
DATA x/t(4, null())/ ! ICE in the middle end
end subroutine test
! ============= (3) =========================
type t
integer, pointer :: ptr
end type t
integer, target, save :: tgt
! Version A:
!type(t) :: x = t(tgt)
! Rejected with "has not been declared or is a variable,
! which does not reduce to a constant expression"
! Version 2
type(t) :: x
DATA x%ptr /tgt/ ! error "must be a PARAMETER in DATA statement"
tgt = 7
print *, ptr
end