1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 ! Check for semantic errors in this_image() function calls
5 program this_image_tests
6 use iso_fortran_env
, only
: team_type
9 !ERROR: Coarray 'team_coarray' may not have type TEAM_TYPE, C_PTR, or C_FUNPTR
10 type(team_type
) team_coarray
[*]
11 type(team_type
) home
, league(2)
12 integer n
, i
, array(1), non_coarray(1), co_array
[*]
13 integer, allocatable
:: images(:)
16 !___ standard-conforming statement with no optional arguments present ___
19 !___ standard-conforming statements with team argument present ___
21 n
= this_image(team
=home
)
22 n
= this_image(league(1))
24 !___ standard-conforming statements with coarray argument present ___
25 images
= this_image(co_array
)
26 images
= this_image(coarray
=co_array
)
28 !___ standard-conforming statements with coarray and team arguments present ___
29 images
= this_image(co_array
, home
)
30 images
= this_image(co_array
, team
=home
)
31 images
= this_image(team_coarray
, team
=home
)
32 images
= this_image(team_coarray
[1], team
=home
)
33 images
= this_image(coarray
=co_array
, team
=home
)
34 images
= this_image(team
=home
, coarray
=co_array
)
36 !___ standard-conforming statements with coarray and dim arguments present ___
37 n
= this_image(co_array
, i
)
38 n
= this_image(co_array
, dim
=i
)
39 n
= this_image(coarray
=co_array
, dim
=i
)
40 n
= this_image(dim
=i
, coarray
=co_array
)
42 !___ standard-conforming statements with all arguments present ___
43 n
= this_image(co_array
, i
, home
)
44 n
= this_image(co_array
, i
, team
=home
)
45 n
= this_image(co_array
, dim
=i
, team
=home
)
46 n
= this_image(co_array
, team
=home
, dim
=i
)
48 n
= this_image(coarray
=co_array
, dim
=i
, team
=home
)
49 n
= this_image(coarray
=co_array
, team
=home
, dim
=i
)
51 n
= this_image(dim
=i
, coarray
=co_array
, team
=home
)
52 n
= this_image(dim
=i
, team
=home
, coarray
=co_array
)
54 n
= this_image(team
=home
, dim
=i
, coarray
=co_array
)
55 n
= this_image(team
=home
, coarray
=co_array
, dim
=i
)
57 !___ non-conforming statements ___
60 n
= this_image(co_array
)
62 !ERROR: missing mandatory 'dim=' argument
65 !ERROR: missing mandatory 'coarray=' argument
68 !ERROR: Actual argument for 'dim=' has bad type 'team_type'
69 n
= this_image(i
, home
)
71 !ERROR: missing mandatory 'dim=' argument
72 n
= this_image(i
, team
=home
)
75 n
= this_image(coarray
=co_array
, dim
=2)
77 !ERROR: missing mandatory 'coarray=' argument
78 n
= this_image(dim
=i
, team
=home
)
80 !ERROR: missing mandatory 'coarray=' argument
81 n
= this_image(team
=home
, dim
=i
)
83 ! Doesn't produce an error
84 n
= this_image(coarray
=co_array
, i
)
86 !ERROR: No explicit type declared for 'team'
87 images
= this_image(coarray
=co_array
, team
)
89 ! non-scalar team_type argument
90 !ERROR: missing mandatory 'coarray=' argument
91 n
= this_image(team
=league
)
93 ! incorrectly typed argument
94 !ERROR: missing mandatory 'dim=' argument
97 !ERROR: too many actual arguments for intrinsic 'this_image'
98 n
= this_image(co_array
, i
, home
, 0)
100 ! keyword argument with incorrect type
101 !ERROR: missing mandatory 'dim=' argument
102 images
= this_image(coarray
=non_coarray
)
104 ! incorrect keyword argument name but valid type (type number)
105 !ERROR: unknown keyword argument to intrinsic 'this_image'
106 images
= this_image(co_array
=co_array
)
108 ! incorrect keyword argument name but valid type (team_type)
109 !ERROR: unknown keyword argument to intrinsic 'this_image'
110 n
= this_image(my_team
=home
)
112 ! correct keyword argument name but mismatched type
113 !ERROR: Actual argument for 'team=' has bad type 'INTEGER(4)'
114 n
= this_image(co_array
, i
, team
=-1)
116 !ERROR: 'dim=' argument has unacceptable rank 1
117 n
= this_image(co_array
, array
)
119 !ERROR: unknown keyword argument to intrinsic 'this_image'
120 n
= this_image(co_array
, dims
=i
)
122 !ERROR: Actual argument for 'dim=' has bad type 'LOGICAL(4)'
123 n
= this_image(co_array
, non_integer
)
125 ! A this_image reference with a coarray argument of team type shall also have a team argument
126 ! Doesn't produce an error
127 images
= this_image(team_coarray
)
128 end program this_image_tests