| 1 |
! { dg-do compile } |
| 2 |
! Some errors pointed out in the development of the patch. |
| 3 |
! |
| 4 |
! Contributed by Tobias Burnus <[email protected]> |
| 5 |
! |
| 6 |
module m |
| 7 |
type :: date |
| 8 |
private |
| 9 |
integer :: yr, mon |
| 10 |
integer,public :: day |
| 11 |
end type |
| 12 |
type :: dt |
| 13 |
integer :: yr, mon |
| 14 |
integer :: day |
| 15 |
end type |
| 16 |
end module m |
| 17 |
|
| 18 |
use m |
| 19 |
type, extends(date) :: datetime |
| 20 |
integer :: hr, min, sec |
| 21 |
end type |
| 22 |
type(datetime) :: o_dt |
| 23 |
|
| 24 |
type :: one |
| 25 |
integer :: i |
| 26 |
end type one |
| 27 |
|
| 28 |
type, extends(one) :: two |
| 29 |
real :: r |
| 30 |
end type two |
| 31 |
|
| 32 |
o_dt%day = 5 ! VALID but failed in first version of EXTENDS patch |
| 33 |
o_dt%yr = 5 ! { dg-error "is a PRIVATE component of" } |
| 34 |
|
| 35 |
t = two(one = one(4), i = 5, r=4.4) ! { dg-error "has already been set" } |
| 36 |
|
| 37 |
call foo |
| 38 |
contains |
| 39 |
subroutine foo |
| 40 |
use m, date_type => dt |
| 41 |
type, extends(date_type) :: dt_type |
| 42 |
end type |
| 43 |
type (dt_type) :: foo_dt |
| 44 |
foo_dt%date_type%day = 1 |
| 45 |
foo_dt%dt%day = 1 ! { dg-error "not a member" } |
| 46 |
end subroutine |
| 47 |
end |