135 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! This test checks for semantic errors in co_max subroutine calls based on3! the co_max interface defined in section 16.9.47 of the Fortran 2018 standard.4 5program test_co_max6 implicit none7 8 integer i, integer_array(1), coindexed_integer[*], status, coindexed_result_image[*], repeated_status9 character(len=1) c, character_array(1), coindexed_character[*], message, repeated_message10 double precision d, double_precision_array(1)11 real r, real_array(1), coindexed_real[*]12 complex complex_type13 logical bool14 15 !___ standard-conforming calls with no keyword arguments ___16 call co_max(i)17 call co_max(c)18 call co_max(d)19 call co_max(r)20 call co_max(i, 1)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)28 29 !___ standard-conforming calls with keyword arguments ___30 31 ! all arguments present32 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)34 35 ! one optional argument not present36 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 )39 40 ! two optional arguments not present41 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] )45 46 ! no optional arguments present47 call co_max(a=i)48 49 !___ non-standard-conforming calls ___50 51 !ERROR: missing mandatory 'a=' argument52 call co_max()53 54 !ERROR: repeated keyword argument to intrinsic 'co_max'55 call co_max(a=i, a=c)56 57 !ERROR: repeated keyword argument to intrinsic 'co_max'58 call co_max(d, result_image=1, result_image=3)59 60 !ERROR: repeated keyword argument to intrinsic 'co_max'61 call co_max(d, 1, stat=status, stat=repeated_status)62 63 !ERROR: repeated keyword argument to intrinsic 'co_max'64 call co_max(d, 1, status, errmsg=message, errmsg=repeated_message)65 66 !ERROR: keyword argument to intrinsic 'co_max' was supplied positionally by an earlier actual argument67 call co_max(i, 1, a=c)68 69 !ERROR: keyword argument to intrinsic 'co_max' was supplied positionally by an earlier actual argument70 call co_max(i, 1, status, result_image=1)71 72 !ERROR: keyword argument to intrinsic 'co_max' was supplied positionally by an earlier actual argument73 call co_max(i, 1, status, stat=repeated_status)74 75 !ERROR: keyword argument to intrinsic 'co_max' was supplied positionally by an earlier actual argument76 call co_max(i, 1, status, message, errmsg=repeated_message)77 78 ! argument 'a' shall be of numeric type79 !ERROR: Actual argument for 'a=' has bad type 'LOGICAL(4)'80 call co_max(bool)81 82 ! argument 'a' shall be of numeric type83 !ERROR: Actual argument for 'a=' has bad type 'COMPLEX(4)'84 call co_max(complex_type)85 86 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'a=' is not definable87 !BECAUSE: '2_4' is not a variable or pointer88 call co_max(a=1+1)89 90 !ERROR: 'a' argument to 'co_max' may not be a coindexed object91 call co_max(a=coindexed_real[1])92 93 !ERROR: Actual argument for 'result_image=' has bad type 'LOGICAL(4)'94 call co_max(i, result_image=bool)95 96 !ERROR: 'result_image=' argument has unacceptable rank 197 call co_max(c, result_image=integer_array)98 99 !ERROR: 'stat' argument to 'co_max' may not be a coindexed object100 call co_max(d, stat=coindexed_integer[1])101 102 ! 'stat' argument shall be an integer103 !ERROR: Actual argument for 'stat=' has bad type 'CHARACTER(KIND=1,LEN=1_8)'104 call co_max(r, stat=message)105 106 !ERROR: 'stat=' argument has unacceptable rank 1107 call co_max(i, stat=integer_array)108 109 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'errmsg=' is not definable110 !BECAUSE: '"c"' is not a variable or pointer111 call co_max(a=i, result_image=1, stat=status, errmsg='c')112 113 !ERROR: 'errmsg' argument to 'co_max' may not be a coindexed object114 call co_max(c, errmsg=coindexed_character[1])115 116 ! 'errmsg' argument shall be a character117 !ERROR: Actual argument for 'errmsg=' has bad type 'INTEGER(4)'118 call co_max(c, errmsg=i)119 120 !ERROR: 'errmsg=' argument has unacceptable rank 1121 call co_max(d, errmsg=character_array)122 123 !ERROR: actual argument #5 without a keyword may not follow an actual argument with a keyword124 call co_max(r, result_image=1, stat=status, errmsg=message, 3.4)125 126 !ERROR: unknown keyword argument to intrinsic 'co_max'127 call co_max(fake=3.4)128 129 !ERROR: 'a' argument to 'co_max' may not be a coindexed object130 !ERROR: 'errmsg' argument to 'co_max' may not be a coindexed object131 !ERROR: 'stat' argument to 'co_max' may not be a coindexed object132 call co_max(result_image=coindexed_result_image[1], a=coindexed_real[1], errmsg=coindexed_character[1], stat=coindexed_integer[1])133 134end program test_co_max135