151 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! This test checks for semantic errors in co_sum subroutine calls based on3! the co_reduce interface defined in section 16.9.50 of the Fortran 2018 standard.4 5program test_co_sum6 implicit none7 8 integer i, status, integer_array(1), coindexed_integer[*], coindexed_result_image[*], repeated_status9 complex c, complex_array(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1)10 double precision d, double_precision_array(1)11 real r, real_array(1), coindexed_real[*]12 13 character(len=1) message, coindexed_character[*], character_array(1), repeated_message14 logical bool15 16 !___ standard-conforming calls with no keyword arguments ___17 call co_sum(i)18 call co_sum(c)19 call co_sum(d)20 call co_sum(r)21 call co_sum(i, 1)22 call co_sum(c, 1, status)23 call co_sum(d, 1, status, message)24 call co_sum(r, 1, status, message)25 call co_sum(integer_array)26 call co_sum(complex_array, 1)27 call co_sum(double_precision_array, 1, status)28 call co_sum(real_array, 1, status, message)29 30 !___ standard-conforming calls with keyword arguments ___31 32 ! all arguments present33 call co_sum(a=i, result_image=1, stat=status, errmsg=message)34 call co_sum(a = i, result_image = 1, stat = status, errmsg = message)35 call co_sum(result_image=1, a=i, errmsg=message, stat=status)36 37 ! one optional argument not present38 call co_sum(a=i, stat=status, errmsg=message)39 call co_sum(a=i, result_image=1, errmsg=message)40 call co_sum(a=i, result_image=1, stat=status )41 42 ! two optional arguments not present43 call co_sum(a=i, result_image=1 )44 call co_sum(a=i, stat=status )45 call co_sum(a=i, errmsg=message)46 call co_sum(a=i, result_image=coindexed_result_image[1])47 48 ! no optional arguments present49 call co_sum(a=i )50 51 !___ non-standard-conforming calls ___52 53 !ERROR: missing mandatory 'a=' argument54 call co_sum()55 56 !ERROR: missing mandatory 'a=' argument57 call co_sum(result_image=1, stat=status, errmsg=message)58 59 !ERROR: repeated keyword argument to intrinsic 'co_sum'60 call co_sum(a=i, a=c)61 62 !ERROR: repeated keyword argument to intrinsic 'co_sum'63 call co_sum(a=i, result_image=1, result_image=2, stat=status, errmsg=message)64 65 !ERROR: repeated keyword argument to intrinsic 'co_sum'66 call co_sum(a=i, result_image=1, stat=status, stat=repeated_status, errmsg=message)67 68 !ERROR: repeated keyword argument to intrinsic 'co_sum'69 call co_sum(a=i, result_image=1, stat=status, errmsg=message, errmsg=repeated_message)70 71 !ERROR: keyword argument to intrinsic 'co_sum' was supplied positionally by an earlier actual argument72 call co_sum(i, 1, a=c)73 74 !ERROR: keyword argument to intrinsic 'co_sum' was supplied positionally by an earlier actual argument75 call co_sum(i, 1, result_image=2)76 77 !ERROR: keyword argument to intrinsic 'co_sum' was supplied positionally by an earlier actual argument78 call co_sum(i, 1, status, stat=repeated_status)79 80 !ERROR: keyword argument to intrinsic 'co_sum' was supplied positionally by an earlier actual argument81 call co_sum(i, 1, status, message, errmsg=repeated_message)82 83 ! argument 'a' shall be of numeric type84 !ERROR: Actual argument for 'a=' has bad type 'LOGICAL(4)'85 call co_sum(bool)86 87 ! argument 'a' is intent(inout)88 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'a=' is not definable89 !BECAUSE: '2_4' is not a variable or pointer90 call co_sum(a=1+1)91 92 !ERROR: 'a' argument to 'co_sum' may not be a coindexed object93 call co_sum(a=coindexed_real[1])94 95 ! 'result_image' argument shall be a integer96 !ERROR: Actual argument for 'result_image=' has bad type 'LOGICAL(4)'97 call co_sum(i, result_image=bool)98 99 ! 'result_image' argument shall be an integer scalar100 !ERROR: 'result_image=' argument has unacceptable rank 1101 call co_sum(c, result_image=integer_array)102 103 ! argument 'stat' shall be intent(out)104 !ERROR: Actual argument associated with INTENT(OUT) dummy argument 'stat=' is not definable105 !BECAUSE: '2_4' is not a variable or pointer106 call co_sum(a=i, result_image=1, stat=1+1, errmsg=message)107 108 !ERROR: 'stat' argument to 'co_sum' may not be a coindexed object109 call co_sum(d, stat=coindexed_integer[1])110 111 !ERROR: 'stat' argument to 'co_sum' may not be a coindexed object112 call co_sum(stat=coindexed_integer[1], a=d)113 114 ! 'stat' argument shall be an integer115 !ERROR: Actual argument for 'stat=' has bad type 'CHARACTER(KIND=1,LEN=1_8)'116 call co_sum(r, stat=message)117 118 ! 'stat' argument shall be an integer scalar119 !ERROR: 'stat=' argument has unacceptable rank 1120 call co_sum(i, stat=integer_array)121 122 ! 'errmsg' argument shall be intent(inout)123 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'errmsg=' is not definable124 !BECAUSE: '"c"' is not a variable or pointer125 call co_sum(a=i, result_image=1, stat=status, errmsg='c')126 127 !ERROR: 'errmsg' argument to 'co_sum' may not be a coindexed object128 call co_sum(c, errmsg=coindexed_character[1])129 130 ! 'errmsg' argument shall be a character131 !ERROR: Actual argument for 'errmsg=' has bad type 'INTEGER(4)'132 call co_sum(c, errmsg=i)133 134 ! 'errmsg' argument shall be character scalar135 !ERROR: 'errmsg=' argument has unacceptable rank 1136 call co_sum(d, errmsg=character_array)137 138 !ERROR: actual argument #5 without a keyword may not follow an actual argument with a keyword139 call co_sum(r, result_image=1, stat=status, errmsg=message, 3.4)140 141 ! keyword argument with incorrect name142 !ERROR: unknown keyword argument to intrinsic 'co_sum'143 call co_sum(fake=3.4)144 145 !ERROR: 'a' argument to 'co_sum' may not be a coindexed object146 !ERROR: 'errmsg' argument to 'co_sum' may not be a coindexed object147 !ERROR: 'stat' argument to 'co_sum' may not be a coindexed object148 call co_sum(result_image=coindexed_result_image[1], a=coindexed_real[1], errmsg=coindexed_character[1], stat=coindexed_integer[1])149 150end program test_co_sum151