1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 ! This test checks for semantic errors in co_max subroutine calls based on
4 ! the co_max interface defined in section 16.9.47 of the Fortran 2018 standard.
5 ! To Do: add co_max to the list of intrinsics
10 integer i
, integer_array(1), coindexed_integer
[*], status
11 character(len
=1) c
, character_array(1), coindexed_character
[*], message
12 double precision d
, double_precision_array(1)
13 real r
, real_array(1), coindexed_real
[*]
17 !___ standard-conforming calls with no keyword arguments ___
23 call co_max(c
, 1, status
)
24 call co_max(d
, 1, status
, message
)
25 call co_max(r
, 1, status
, message
)
26 call co_max(integer_array
)
27 call co_max(character_array
, 1)
28 call co_max(double_precision_array
, 1, status
)
29 call co_max(real_array
, 1, status
, message
)
31 !___ standard-conforming calls with keyword arguments ___
33 ! all arguments present
34 call co_max(a
=i
, result_image
=1, stat
=status
, errmsg
=message
)
35 call co_max(result_image
=1, a
=i
, errmsg
=message
, stat
=status
)
37 ! one optional argument not present
38 call co_max(a
=i
, stat
=status
, errmsg
=message
)
39 call co_max(a
=i
, result_image
=1, errmsg
=message
)
40 call co_max(a
=i
, result_image
=1, stat
=status
)
42 ! two optional arguments not present
43 call co_max(a
=i
, result_image
=1 )
44 call co_max(a
=i
, stat
=status
)
45 call co_max(a
=i
, errmsg
=message
)
47 ! no optional arguments present
50 !___ non-standard-conforming calls ___
52 ! argument 'a' shall be of numeric type
53 !ERROR: Actual argument for 'a=' has bad type 'LOGICAL(4)'
56 ! argument 'a' shall be of numeric type
57 !ERROR: Actual argument for 'a=' has bad type 'COMPLEX(4)'
58 call co_max(complex_type
)
60 ! argument 'a' is intent(inout)
61 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'a=' must be definable
64 ! argument 'a' shall not be a coindexed object
65 !ERROR: to be determined
66 call co_max(a
=coindexed_real
[1])
68 ! 'result_image' argument shall be a scalar
69 !ERROR: too many actual arguments for intrinsic 'co_max'
70 call co_max(i
, result_image
=bool
)
72 ! 'result_image' argument shall be an integer scalar
73 !ERROR: too many actual arguments for intrinsic 'co_max'
74 call co_max(c
, result_image
=integer_array
)
76 ! 'stat' argument shall be noncoindexed
77 !ERROR: to be determined
78 call co_max(d
, stat
=coindexed_integer
[1])
80 ! 'stat' argument shall be an integer
81 !ERROR: Actual argument for 'stat=' has bad type 'CHARACTER(KIND=1,LEN=1_8)'
82 call co_max(r
, stat
=message
)
84 ! 'stat' argument shall be an integer scalar
85 !ERROR: 'stat=' argument has unacceptable rank 1
86 call co_max(i
, stat
=integer_array
)
88 ! 'errmsg' argument shall be noncoindexed
89 !ERROR: to be determined
90 call co_max(c
, errmsg
=coindexed_character
[1])
92 ! 'errmsg' argument shall be character scalar
93 !ERROR: 'errmsg=' argument has unacceptable rank 1
94 call co_max(d
, errmsg
=character_array
)
96 ! the error is seen as too many arguments to the co_max() call
97 !ERROR: too many actual arguments for intrinsic 'co_max'
98 call co_max(r
, result_image
=1, stat
=status
, errmsg
=message
, 3.4)
100 ! keyword argument with incorrect name
101 !ERROR: unknown keyword argument to intrinsic 'co_max'
102 call co_max(fake
=3.4)
104 end program test_co_max