1! RUN: %S/test_errors.sh %s %t %f18 2! Error tests for structure constructors: per-component type 3! (in)compatibility. 4 5module module1 6 interface 7 real function realfunc(x) 8 real, value :: x 9 end function realfunc 10 end interface 11 type :: scalar(ik,rk,zk,ck,lk,len) 12 integer, kind :: ik = 4, rk = 4, zk = 4, ck = 1, lk = 1 13 integer, len :: len = 1 14 integer(kind=ik) :: ix = 0 15 real(kind=rk) :: rx = 0. 16 complex(kind=zk) :: zx = (0.,0.) 17 character(kind=ck,len=len) :: cx = ' ' 18 logical(kind=lk) :: lx = .false. 19 real(kind=rk), pointer :: rp => NULL() 20 procedure(realfunc), pointer, nopass :: rfp1 => NULL() 21 procedure(real), pointer, nopass :: rfp2 => NULL() 22 end type scalar 23 contains 24 subroutine scalararg(x) 25 type(scalar), intent(in) :: x 26 end subroutine scalararg 27 subroutine errors 28 call scalararg(scalar(4)(ix=1,rx=2.,zx=(3.,4.),cx='a',lx=.true.)) 29 call scalararg(scalar(4)(1,2.,(3.,4.),'a',.true.)) 30! call scalararg(scalar(4)(ix=5.,rx=6,zx=(7._8,8._2),cx=4_'b',lx=.true._4)) 31! call scalararg(scalar(4)(5.,6,(7._8,8._2),4_'b',.true._4)) 32 call scalararg(scalar(4)(ix=5.,rx=6,zx=(7._8,8._2),cx=4_'b',lx=.true.)) 33 call scalararg(scalar(4)(5.,6,(7._8,8._2),4_'b',.true.)) 34 !ERROR: Value in structure constructor of type CHARACTER(1) is incompatible with component 'ix' of type INTEGER(4) 35 call scalararg(scalar(4)(ix='a')) 36 !ERROR: Value in structure constructor of type LOGICAL(4) is incompatible with component 'ix' of type INTEGER(4) 37 call scalararg(scalar(4)(ix=.false.)) 38 !ERROR: Rank-1 array value is not compatible with scalar component 'ix' 39 call scalararg(scalar(4)(ix=[1])) 40 !TODO more! 41 end subroutine errors 42end module module1 43