Update ChangeLog and version files for release
[official-gcc.git] / gcc / testsuite / gfortran.dg / derived_constructor_comps_1.f90
blob1c02a31c7a319855d0d8317b8b8f78dbef73a7c0
1 ! { dg-do run }
3 ! Tests fix for PR28425 in which anything other than a constructor would
4 ! not work for derived type components in a structure constructor.
6 ! Original version sent by Vivek Rao on 18 Jan 06
7 ! Modified by Steve Kargl to remove IO
9 module foo_mod
11 implicit none
13 type :: date_m
14 integer :: month
15 end type date_m
17 type :: file_info
18 type(date_m) :: date
19 end type file_info
21 end module foo_mod
23 program prog
25 use foo_mod
27 implicit none
28 type(date_m) :: dat
29 type(file_info) :: xx
31 type(date_m), parameter :: christmas = date_m (12)
33 dat = date_m(1)
35 xx = file_info(date_m(-1)) ! This always worked - a constructor
36 if (xx%date%month /= -1) call abort
38 xx = file_info(dat) ! This was the original PR - a variable
39 if (xx%date%month /= 1) call abort
41 xx = file_info(foo(2)) ! ...functions were also broken
42 if (xx%date%month /= 2) call abort
44 xx = file_info(christmas) ! ...and parameters
45 if (xx%date%month /= 12) call abort
48 contains
50 function foo (i) result (ans)
51 integer :: i
52 type(date_m) :: ans
53 ans = date_m(i)
54 end function foo
56 end program prog