1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! This test checks for semantic errors in co_max subroutine calls based on
3 ! the co_max interface defined in section 16.9.47 of the Fortran 2018 standard.
8 integer i
, integer_array(1), coindexed_integer
[*], status
, coindexed_result_image
[*], repeated_status
9 character(len
=1) c
, character_array(1), coindexed_character
[*], message
, repeated_message
10 double precision d
, double_precision_array(1)
11 real r
, real_array(1), coindexed_real
[*]
15 !___ standard-conforming calls with no keyword arguments ___
21 call co_max(c
, 1, status
)
22 call co_max(d
, 1, status
, message
)
23 call co_max(r
, 1, status
, message
)
24 call co_max(integer_array
)
25 call co_max(character_array
, 1)
26 call co_max(double_precision_array
, 1, status
)
27 call co_max(real_array
, 1, status
, message
)
29 !___ standard-conforming calls with keyword arguments ___
31 ! all arguments present
32 call co_max(a
=i
, result_image
=1, stat
=status
, errmsg
=message
)
33 call co_max(result_image
=1, a
=i
, errmsg
=message
, stat
=status
)
35 ! one optional argument not present
36 call co_max(a
=i
, stat
=status
, errmsg
=message
)
37 call co_max(a
=i
, result_image
=1, errmsg
=message
)
38 call co_max(a
=i
, result_image
=1, stat
=status
)
40 ! two optional arguments not present
41 call co_max(a
=i
, result_image
=1 )
42 call co_max(a
=i
, stat
=status
)
43 call co_max(a
=i
, errmsg
=message
)
44 call co_max(a
=i
, result_image
=coindexed_result_image
[1] )
46 ! no optional arguments present
49 !___ non-standard-conforming calls ___
51 !ERROR: missing mandatory 'a=' argument
54 !ERROR: repeated keyword argument to intrinsic 'co_max'
57 !ERROR: repeated keyword argument to intrinsic 'co_max'
58 call co_max(d
, result_image
=1, result_image
=3)
60 !ERROR: repeated keyword argument to intrinsic 'co_max'
61 call co_max(d
, 1, stat
=status
, stat
=repeated_status
)
63 !ERROR: repeated keyword argument to intrinsic 'co_max'
64 call co_max(d
, 1, status
, errmsg
=message
, errmsg
=repeated_message
)
66 !ERROR: keyword argument to intrinsic 'co_max' was supplied positionally by an earlier actual argument
67 call co_max(i
, 1, a
=c
)
69 !ERROR: keyword argument to intrinsic 'co_max' was supplied positionally by an earlier actual argument
70 call co_max(i
, 1, status
, result_image
=1)
72 !ERROR: keyword argument to intrinsic 'co_max' was supplied positionally by an earlier actual argument
73 call co_max(i
, 1, status
, stat
=repeated_status
)
75 !ERROR: keyword argument to intrinsic 'co_max' was supplied positionally by an earlier actual argument
76 call co_max(i
, 1, status
, message
, errmsg
=repeated_message
)
78 ! argument 'a' shall be of numeric type
79 !ERROR: Actual argument for 'a=' has bad type 'LOGICAL(4)'
82 ! argument 'a' shall be of numeric type
83 !ERROR: Actual argument for 'a=' has bad type 'COMPLEX(4)'
84 call co_max(complex_type
)
86 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'a=' is not definable
87 !BECAUSE: '2_4' is not a variable or pointer
90 !ERROR: 'a' argument to 'co_max' may not be a coindexed object
91 call co_max(a
=coindexed_real
[1])
93 !ERROR: Actual argument for 'result_image=' has bad type 'LOGICAL(4)'
94 call co_max(i
, result_image
=bool
)
96 !ERROR: 'result_image=' argument has unacceptable rank 1
97 call co_max(c
, result_image
=integer_array
)
99 !ERROR: 'stat' argument to 'co_max' may not be a coindexed object
100 call co_max(d
, stat
=coindexed_integer
[1])
102 ! 'stat' argument shall be an integer
103 !ERROR: Actual argument for 'stat=' has bad type 'CHARACTER(KIND=1,LEN=1_8)'
104 call co_max(r
, stat
=message
)
106 !ERROR: 'stat=' argument has unacceptable rank 1
107 call co_max(i
, stat
=integer_array
)
109 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'errmsg=' is not definable
110 !BECAUSE: '"c"' is not a variable or pointer
111 call co_max(a
=i
, result_image
=1, stat
=status
, errmsg
='c')
113 !ERROR: 'errmsg' argument to 'co_max' may not be a coindexed object
114 call co_max(c
, errmsg
=coindexed_character
[1])
116 ! 'errmsg' argument shall be a character
117 !ERROR: Actual argument for 'errmsg=' has bad type 'INTEGER(4)'
118 call co_max(c
, errmsg
=i
)
120 !ERROR: 'errmsg=' argument has unacceptable rank 1
121 call co_max(d
, errmsg
=character_array
)
123 !ERROR: actual argument #5 without a keyword may not follow an actual argument with a keyword
124 call co_max(r
, result_image
=1, stat
=status
, errmsg
=message
, 3.4)
126 !ERROR: unknown keyword argument to intrinsic 'co_max'
127 call co_max(fake
=3.4)
129 !ERROR: 'a' argument to 'co_max' may not be a coindexed object
130 !ERROR: 'errmsg' argument to 'co_max' may not be a coindexed object
131 !ERROR: 'stat' argument to 'co_max' may not be a coindexed object
132 call co_max(result_image
=coindexed_result_image
[1], a
=coindexed_real
[1], errmsg
=coindexed_character
[1], stat
=coindexed_integer
[1])
134 end program test_co_max