1
1
! RUN: %python %S/test_errors.py %s %flang_fc1
2
- ! XFAIL: *
3
2
! Check for semantic errors in coshape() function,
4
3
! as defined in section 16.9.55 of the Fortran
5
4
! 2018 standard
@@ -8,18 +7,21 @@ program coshape_tests
8
7
use iso_c_binding, only : c_int32_t, c_int64_t
9
8
implicit none
10
9
10
+ type t
11
+ real x
12
+ end type
11
13
integer array(1 ), non_coarray(1 ), scalar_coarray[* ], array_coarray(1 )[* ], non_constant, scalar_result
12
14
real real_coarray[* ]
13
15
complex complex_coarray[* ]
14
16
character char_array(1 )
15
17
logical non_integer, logical_coarray[* ]
18
+ type (t) derived_scalar_coarray[* ], derived_array_coarray(1 )[* ]
16
19
integer , allocatable :: codimensions(:)
17
20
18
21
! ___ standard-conforming statement with no optional arguments present ___
19
22
codimensions = coshape(scalar_coarray)
20
23
codimensions = coshape(array_coarray)
21
24
codimensions = coshape(array_coarray(1 ))
22
- codimensions = coshape(scalar_coarray[1 ])
23
25
codimensions = coshape(real_coarray)
24
26
codimensions = coshape(logical_coarray)
25
27
codimensions = coshape(complex_coarray)
@@ -33,54 +35,79 @@ program coshape_tests
33
35
34
36
! ___ non-conforming statements ___
35
37
! coarray argument must be a coarray
38
+ ! ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'coshape'
36
39
codimensions = coshape(non_coarray)
40
+ ! ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'coshape'
41
+ codimensions = coshape(derived_scalar_coarray[1 ]% x)
42
+ ! ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'coshape'
43
+ codimensions = coshape(derived_array_coarray[1 ]% x)
44
+ ! ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'coshape'
45
+ codimensions = coshape(array_coarray[1 ])
46
+ ! ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'coshape'
47
+ codimensions = coshape(scalar_coarray[1 ])
37
48
38
49
! kind argument must be an integer
50
+ ! ERROR: Actual argument for 'kind=' has bad type 'LOGICAL(4)'
39
51
codimensions = coshape(scalar_coarray, non_integer)
40
52
41
53
! kind argument must be a constant expression
54
+ ! ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
42
55
codimensions = coshape(real_coarray, non_constant)
43
56
44
57
! kind argument must be an integer scalar
58
+ ! ERROR: 'kind=' argument has unacceptable rank 1
45
59
codimensions = coshape(complex_coarray, array)
46
60
47
61
! missing all arguments
62
+ ! ERROR: missing mandatory 'coarray=' argument
48
63
codimensions = coshape()
49
64
50
65
! missing mandatory argument
66
+ ! ERROR: missing mandatory 'coarray=' argument
51
67
codimensions = coshape(kind= c_int32_t)
52
68
53
69
! incorrect typing for mandatory argument
70
+ ! ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'coshape'
54
71
codimensions = coshape(3.4 )
55
72
56
73
! incorrect typing for coarray argument
74
+ ! ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'coshape'
57
75
codimensions = coshape(coarray= 3.4 )
58
76
59
77
! too many arguments
78
+ ! ERROR: too many actual arguments for intrinsic 'coshape'
60
79
codimensions = coshape(scalar_coarray, c_int32_t, 0 )
61
80
62
81
! incorrect typing with correct keyword for coarray argument
82
+ ! ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'coshape'
63
83
codimensions = coshape(coarray= non_coarray)
64
84
65
85
! correct typing with incorrect keyword for coarray argument
86
+ ! ERROR: unknown keyword argument to intrinsic 'coshape'
66
87
codimensions = coshape(c= real_coarray)
67
88
68
89
! incorrect typing with correct keyword for kind argument
90
+ ! ERROR: Actual argument for 'kind=' has bad type 'LOGICAL(4)'
69
91
codimensions = coshape(complex_coarray, kind= non_integer)
70
92
71
93
! correct typing with incorrect keyword for kind argument
94
+ ! ERROR: unknown keyword argument to intrinsic 'coshape'
72
95
codimensions = coshape(logical_coarray, kinds= c_int32_t)
73
96
74
97
! repeated keyword for coarray argument
98
+ ! ERROR: repeated keyword argument to intrinsic 'coshape'
75
99
codimensions = coshape(coarray= scalar_coarray, coarray= real_coarray)
76
100
77
101
! repeated keyword for kind argument
102
+ ! ERROR: repeated keyword argument to intrinsic 'coshape'
78
103
codimensions = coshape(real_coarray, kind= c_int32_t, kind= c_int64_t)
79
104
80
105
! result must be a rank 1 array
106
+ ! ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)
81
107
scalar_result = coshape(scalar_coarray)
82
108
83
109
! result must be an integer array
110
+ ! ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types CHARACTER(KIND=1) and INTEGER(4)
84
111
char_array = coshape(real_coarray)
85
112
86
113
end program coshape_tests
0 commit comments