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