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