brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · b6558c0 Raw
101 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Confirm enforcement of constraints and restrictions in 7.83! C7110, C7111, C7112, C7113, C7114, C71154 5subroutine arrayconstructorvalues(asize)6  integer :: intarray(4)7  integer(KIND=8) :: k8 = 208  integer, intent(in) :: asize(*)9 10  TYPE EMPLOYEE11    INTEGER AGE12    CHARACTER (LEN = 30) NAME13  END TYPE EMPLOYEE14  TYPE EMPLOYEER15    CHARACTER (LEN = 30) NAME16  END TYPE EMPLOYEER17 18  TYPE(EMPLOYEE) :: emparray(3)19  class(*), pointer :: unlim_polymorphic20  TYPE, ABSTRACT :: base_type21    INTEGER :: CARPRIZE22  END TYPE23  ! Different declared type24  !ERROR: Values in array constructor must have the same declared type when no explicit type appears25  intarray = (/ 1, 2, 3, 4., 5/)  ! C711026  ! Different kind type parameter27  !ERROR: Values in array constructor must have the same declared type when no explicit type appears28  intarray = (/ 1,2,3,4, k8 /)    ! C711029 30  ! C711131  !ERROR: Value in array constructor of type 'LOGICAL(4)' could not be converted to the type of the array 'INTEGER(4)'32  intarray = [integer:: .true., 2, 3, 4, 5]33  !ERROR: Value in array constructor of type 'CHARACTER(KIND=1,LEN=22_8)' could not be converted to the type of the array 'INTEGER(4)'34  intarray = [integer:: "RAM stores information", 2, 3, 4, 5]35  !ERROR: Value in array constructor of type 'employee' could not be converted to the type of the array 'INTEGER(4)'36  intarray = [integer:: EMPLOYEE (19, "Jack"), 2, 3, 4, 5]37 38  ! C711239  !ERROR: Dimension 1 of left-hand side has extent 3, but right-hand side has extent 240  !ERROR: Value in array constructor of type 'INTEGER(4)' could not be converted to the type of the array 'employee'41  emparray = (/ EMPLOYEE:: EMPLOYEE(19, "Ganesh"), EMPLOYEE(22, "Omkar"), 19 /)42  !ERROR: Dimension 1 of left-hand side has extent 3, but right-hand side has extent 243  !ERROR: Value in array constructor of type 'employeer' could not be converted to the type of the array 'employee'44  emparray = (/ EMPLOYEE:: EMPLOYEE(19, "Ganesh"), EMPLOYEE(22, "Ram"),EMPLOYEER("ShriniwasPvtLtd") /)45 46  ! C711347  !ERROR: Cannot have an unlimited polymorphic value in an array constructor48  intarray = (/ unlim_polymorphic, 2, 3, 4, 5/)49 50  ! C7114, F'2023 C712551  !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types INTEGER(4) and TYPE(base_type)52  !ERROR: ABSTRACT derived type 'base_type' may not be used in a structure constructor53  !ERROR: An item whose declared type is ABSTRACT may not appear in an array constructor54  !ERROR: Values in array constructor must have the same declared type when no explicit type appears55  intarray = (/ base_type(10), 2, 3, 4, 5 /)56 57  !ERROR: Item is not suitable for use in an array constructor58  intarray(1:1) = [ arrayconstructorvalues ]59 60  !ERROR: Whole assumed-size array 'asize' may not appear here without subscripts61  intarray = [ asize ]62end subroutine arrayconstructorvalues63subroutine checkC7115()64  real, dimension(10), parameter :: good1 = [(99.9, i = 1, 10)]65  real, dimension(100), parameter :: good2 = [((88.8, i = 1, 10), j = 1, 10)]66  real, dimension(-1:0), parameter :: good3 = [77.7, 66.6]67  !ERROR: Implied DO index 'i' is active in a surrounding implied DO loop and may not have the same name68  real, dimension(100), parameter :: bad = [((88.8, i = 1, 10), i = 1, 10)]69 70  !ERROR: Value of named constant 'bad2' ([INTEGER(4)::(int(j,kind=4),INTEGER(8)::j=1_8,1_8,0_8)]) cannot be computed as a constant value71  !ERROR: The stride of an implied DO loop must not be zero72  integer, parameter :: bad2(*) = [(j, j=1,1,0)]73  integer, parameter, dimension(-1:0) :: negLower = (/343,512/)74  integer, parameter, dimension(-1:0) :: negLower1 = ((/343,512/))75 76  real :: local77 78  local = good3(0)79  !ERROR: Subscript value (2) is out of range on dimension 1 in reference to a constant array value80  local = good3(2)81  call inner(negLower(:)) ! OK82  call inner(negLower1(:)) ! OK83 84  contains85    subroutine inner(arg)86      integer :: arg(:)87    end subroutine inner88end subroutine checkC711589subroutine checkOkDuplicates90  real :: realArray(21) = &91    [ ((1.0, iDuplicate = 1,j), &92       (0.0, iDuplicate = j,3 ), &93        j = 1,5 ) ]94end subroutine95subroutine charLengths(c, array)96  character(3) :: c97  character(3) :: array(2)98  !No error should ensue for distinct but compatible DynamicTypes99  array = ["abc", c]100end subroutine101