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