brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.7 KiB · a34930e Raw
187 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Initializer error tests3 4subroutine objectpointers(j)5  integer, intent(in) :: j6  real, allocatable, target, save :: x17  real, codimension[*], target, save :: x28  real, save :: x39  real, target :: x410  real, target, save :: x5(10)11  real, pointer :: x612  type t113    real, allocatable :: c114    real, allocatable, codimension[:] :: c215    real :: c316    real :: c4(10)17    real, pointer :: c518  end type19  type(t1), target, save :: o120  type(t1), save :: o221!ERROR: Local variable 'o3' without the SAVE or ALLOCATABLE attribute may not have a coarray potential subobject component '%c2'22  type(t1), target :: o323!ERROR: An initial data target may not be a reference to an ALLOCATABLE 'x1'24  real, pointer :: p1 => x125!ERROR: An initial data target may not be a reference to a coarray 'x2'26  real, pointer :: p2 => x227!ERROR: An initial data target may not be a reference to an object 'x3' that lacks the TARGET attribute28  real, pointer :: p3 => x329!ERROR: An initial data target may not be a reference to an object 'x4' that lacks the SAVE attribute30  real, pointer :: p4 => x431!ERROR: An initial data target must be a designator with constant subscripts32  real, pointer :: p5 => x5(j)33!ERROR: Pointer has rank 0 but target has rank 134  real, pointer :: p6 => x535!ERROR: An initial data target may not be a reference to a POINTER 'x6'36  real, pointer :: p7 => x637!ERROR: An initial data target may not be a reference to an ALLOCATABLE 'c1'38  real, pointer :: p1o => o1%c139!ERROR: An initial data target may not be a reference to a coarray 'c2'40  real, pointer :: p2o => o1%c241!ERROR: An initial data target may not be a reference to an object 'o2' that lacks the TARGET attribute42  real, pointer :: p3o => o2%c343!ERROR: An initial data target may not be a reference to an object 'o3' that lacks the SAVE attribute44  real, pointer :: p4o => o3%c345!ERROR: An initial data target must be a designator with constant subscripts46  real, pointer :: p5o => o1%c4(j)47!ERROR: Pointer has rank 0 but target has rank 148  real, pointer :: p6o => o1%c449!ERROR: An initial data target may not be a reference to a POINTER 'c5'50  real, pointer :: p7o => o1%c551  type t252    !ERROR: An initial data target may not be a reference to an ALLOCATABLE 'x1'53    real, pointer :: p1 => x154    !ERROR: An initial data target may not be a reference to a coarray 'x2'55    real, pointer :: p2 => x256    !ERROR: An initial data target may not be a reference to an object 'x3' that lacks the TARGET attribute57    real, pointer :: p3 => x358    !ERROR: An initial data target may not be a reference to an object 'x4' that lacks the SAVE attribute59    real, pointer :: p4 => x460    !ERROR: An initial data target must be a designator with constant subscripts61    real, pointer :: p5 => x5(j)62    !ERROR: Pointer has rank 0 but target has rank 163    real, pointer :: p6 => x564    !ERROR: An initial data target may not be a reference to a POINTER 'x6'65    real, pointer :: p7 => x666    !ERROR: An initial data target may not be a reference to an ALLOCATABLE 'c1'67    real, pointer :: p1o => o1%c168    !ERROR: An initial data target may not be a reference to a coarray 'c2'69    real, pointer :: p2o => o1%c270    !ERROR: An initial data target may not be a reference to an object 'o2' that lacks the TARGET attribute71    real, pointer :: p3o => o2%c372    !ERROR: An initial data target may not be a reference to an object 'o3' that lacks the SAVE attribute73    real, pointer :: p4o => o3%c374    !ERROR: An initial data target must be a designator with constant subscripts75    real, pointer :: p5o => o1%c4(j)76    !ERROR: Pointer has rank 0 but target has rank 177    real, pointer :: p6o => o1%c478    !ERROR: An initial data target may not be a reference to a POINTER 'c5'79    real, pointer :: p7o => o1%c580  end type81 82!TODO: type incompatibility, non-deferred type parameter values, contiguity83 84end subroutine85 86subroutine dataobjects(j)87  integer, intent(in) :: j88  real, parameter :: x1(*) = [1., 2.]89!ERROR: Implied-shape parameter 'x2' has rank 2 but its initializer has rank 190  real, parameter :: x2(*,*) = [1., 2.]91!ERROR: Named constant 'x3' array must have constant shape92  real, parameter :: x3(j) = [1., 2.]93!ERROR: Shape of initialized object 'x4' must be constant94  real :: x4(j) = [1., 2.]95!ERROR: Rank of initialized object is 2, but initialization expression has rank 196  real :: x5(2,2) = [1., 2., 3., 4.]97  real :: x6(2,2) = 5.98!ERROR: Rank of initialized object is 0, but initialization expression has rank 199  real :: x7 = [1.]100  real :: x8(2,2) = reshape([1., 2., 3., 4.], [2, 2])101!ERROR: Dimension 1 of initialized object has extent 3, but initialization expression has extent 2102  real :: x9(3) = [1., 2.]103!ERROR: Dimension 1 of initialized object has extent 2, but initialization expression has extent 3104  real :: x10(2,3) = reshape([real::(k,k=1,6)], [3, 2])105end subroutine106 107subroutine components(n)108  integer, intent(in) :: n109  real, target, save :: a1(3)110  real, target :: a2111  real, save :: a3112  real, target, save :: a4113  type :: t1114!ERROR: Dimension 1 of initialized object has extent 2, but initialization expression has extent 3115    real :: x1(2) = [1., 2., 3.]116  end type117  type :: t2(kind, len)118    integer, kind :: kind119    integer, len :: len120!ERROR: Dimension 1 of initialized object has extent 2, but initialization expression has extent 3121!ERROR: Dimension 1 of initialized object has extent 2, but initialization expression has extent 3122    real :: x1(2) = [1., 2., 3.]123!ERROR: Dimension 1 of initialized object has extent 2, but initialization expression has extent 3124    real :: x2(kind) = [1., 2., 3.]125!ERROR: Dimension 1 of initialized object has extent 2, but initialization expression has extent 3126!ERROR: Shape of initialized object 'x3' must be constant127    real :: x3(len) = [1., 2., 3.]128    real, pointer :: p1(:) => a1129!ERROR: An initial data target may not be a reference to an object 'a2' that lacks the SAVE attribute130!ERROR: An initial data target may not be a reference to an object 'a2' that lacks the SAVE attribute131    real, pointer :: p2 => a2132!ERROR: An initial data target may not be a reference to an object 'a3' that lacks the TARGET attribute133!ERROR: An initial data target may not be a reference to an object 'a3' that lacks the TARGET attribute134    real, pointer :: p3 => a3135!ERROR: Pointer has rank 0 but target has rank 1136!ERROR: Pointer has rank 0 but target has rank 1137    real, pointer :: p4 => a1138!ERROR: Pointer has rank 1 but target has rank 0139!ERROR: Pointer has rank 1 but target has rank 0140    real, pointer :: p5(:) => a4141  end type142  type(t2(3,2)) :: o1143  type(t2(2,n)) :: o2144  type :: t3145    real :: x146  end type147  type(t3), save, target :: o3148  real, pointer :: p10 => o3%x149  associate (a1 => o3, a2 => o3%x)150    block151      type(t3), pointer :: p11 => a1152      real, pointer :: p12 => a2153    end block154  end associate155end subroutine156 157subroutine notObjects158!ERROR: 'x1' is not an object that can be initialized159  real, external :: x1 = 1.160!ERROR: 'x2' is not a pointer but is initialized like one161  real, external :: x2 => sin162!ERROR: 'x3' is not a known intrinsic procedure163!ERROR: 'x3' is not an object that can be initialized164  real, intrinsic :: x3 = 1.165!ERROR: 'x4' is not a known intrinsic procedure166!ERROR: 'x4' is not a pointer but is initialized like one167  real, intrinsic :: x4 => cos168end subroutine169 170subroutine edgeCases171  integer :: j = 1, m = 2172  !ERROR: Data statement object must be a variable173  data k/3/174  data n/4/175  !ERROR: Named constant 'j' already has a value176  parameter(j = 5)177  !ERROR: Named constant 'k' already has a value178  parameter(k = 6)179  parameter(l = 7)180  !ERROR: 'm' was initialized earlier as a scalar181  dimension m(1)182  !ERROR: 'l' was initialized earlier as a scalar183  dimension l(1)184  !ERROR: 'n' was initialized earlier as a scalar185  dimension n(1)186end187