1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
6 ! RESHAPE with arguments SOURCE and SHAPE
7 integer, parameter :: array1(2,3) = RESHAPE([(n
, n
=1,6)], [2,3])
8 ! RESHAPE with arguments SOURCE, SHAPE, and PAD
9 integer :: array2(2,3) = RESHAPE([(n
, n
=1,4)], [2,3], [99])
10 ! RESHAPE with arguments SOURCE, SHAPE, PAD, and ORDER
11 integer :: array3(2,3) = RESHAPE([(n
, n
=1,4)], [2,3], [99], [2, 1])
12 !ERROR: Too few elements in 'source=' argument and 'pad=' argument is not present or has null size
13 integer :: array4(2,3) = RESHAPE([(n
, n
=1,5)], [2,3])
14 !ERROR: Actual argument for 'shape=' has bad type 'REAL(4)'
15 integer :: array5(2,3) = RESHAPE([(n
, n
=1,6)], [2.2,3.3])
16 !ERROR: 'shape=' argument must be an array of rank 1
17 integer :: array6(2,3) = RESHAPE([(n
, n
=1,6)], RESHAPE([(n
, n
=1,6)], [2,3]))
18 !ERROR: 'shape=' argument must be an array of rank 1
19 integer :: array7(2,3) = RESHAPE([(n
, n
=1,4)], 343)
20 !ERROR: Actual argument for 'pad=' has bad type or kind 'INTEGER(8)'
21 integer :: array8(2,3) = RESHAPE([(n
, n
=1,4)], [2,3], [99_8])
22 !ERROR: Actual argument for 'pad=' has bad type or kind 'REAL(4)'
23 real :: array9(2,3) = RESHAPE([(n
, n
=1,4)], [2,3], [99.9])
24 !ERROR: Invalid 'order=' argument in RESHAPE
25 real :: array10(2,3) = RESHAPE([(n
,n
=1,4)],[2,3],[99],[2,3])
26 !ERROR: Actual argument for 'order=' has bad type 'REAL(4)'
27 real :: array11(2,3) = RESHAPE([(n
, n
=1,4)], [2,3], [99], [2.2,3.3])
28 !ERROR: Invalid 'order=' argument in RESHAPE
29 real :: array12(2,3) = RESHAPE([(n
, n
=1,4)], [2,3], [99], [1])
30 !ERROR: Invalid 'order=' argument in RESHAPE
31 real :: array13(2,3) = RESHAPE([(n
, n
= 1, 4)], [2, 3], [99], [1, 1])
33 ! Examples that have caused problems
34 integer :: array14(0,0,0) = RESHAPE([(n
,n
=1,0)],[0,0,0])
35 integer, parameter :: array15(1) = RESHAPE([(n
,n
=1,2)],[1])
36 integer, parameter :: array16(1) = RESHAPE([(n
,n
=1,8)],[1], [0], array15
)
37 integer, parameter, dimension(3,4) :: array17
= 3
38 integer, parameter, dimension(3,4) :: array18
= RESHAPE(array17
, [3,4])
39 ! Implicit reshape of array of components
43 type(dType
), parameter :: array19(*) = [dType
::dType(field
=[1,2])]
44 logical, parameter :: lVar
= all(array19(:)%field(1) == [2])
46 !ERROR: Size of 'shape=' argument must not be greater than 15
47 CALL ext_sub(RESHAPE([(n
, n
=1,20)], &
48 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))
49 !ERROR: 'shape=' argument must not have a negative extent
50 CALL ext_sub(RESHAPE([(n
, n
=1,20)], [1, -5, 3]))