xref: /llvm-project/flang/test/Semantics/image_status.f90 (revision 9bb18a983f2f41dc0f933f1263678e66ee912fa8)
1*9bb18a98SKatherine Rasmussen! RUN: %python %S/test_errors.py %s %flang_fc1
2*9bb18a98SKatherine Rasmussen! Check for semantic errors in image_status(), as defined in
3*9bb18a98SKatherine Rasmussen! section 16.9.98 of the Fortran 2018 standard
4*9bb18a98SKatherine Rasmussen
5*9bb18a98SKatherine Rasmussenprogram test_image_status
6*9bb18a98SKatherine Rasmussen  use iso_fortran_env, only : team_type, stat_failed_image, stat_stopped_image
7*9bb18a98SKatherine Rasmussen  implicit none
8*9bb18a98SKatherine Rasmussen
9*9bb18a98SKatherine Rasmussen  type(team_type) home, league(2)
10*9bb18a98SKatherine Rasmussen  integer n, image_num, array(5), coindexed[*], non_array_result, array_2d(10, 10), not_team_type
11*9bb18a98SKatherine Rasmussen  integer, parameter :: array_with_negative(2) = [-2, 1]
12*9bb18a98SKatherine Rasmussen  integer, parameter :: array_with_zero(2) = [1, 0]
13*9bb18a98SKatherine Rasmussen  integer, parameter :: constant_integer = 2, constant_negative = -4, constant_zero = 0
14*9bb18a98SKatherine Rasmussen  integer, allocatable :: result_array(:), result_array_2d(:,:), wrong_rank_result(:)
15*9bb18a98SKatherine Rasmussen  logical wrong_arg_type_logical
16*9bb18a98SKatherine Rasmussen  real wrong_arg_type_real
17*9bb18a98SKatherine Rasmussen  character wrong_result_type
18*9bb18a98SKatherine Rasmussen
19*9bb18a98SKatherine Rasmussen  !___ standard-conforming statements ___
20*9bb18a98SKatherine Rasmussen  n = image_status(1)
21*9bb18a98SKatherine Rasmussen  n = image_status(constant_integer)
22*9bb18a98SKatherine Rasmussen  n = image_status(image_num)
23*9bb18a98SKatherine Rasmussen  n = image_status(array(1))
24*9bb18a98SKatherine Rasmussen  n = image_status(coindexed[1])
25*9bb18a98SKatherine Rasmussen  n = image_status(image=1)
26*9bb18a98SKatherine Rasmussen  result_array = image_status(array)
27*9bb18a98SKatherine Rasmussen  result_array_2d = image_status(array_2d)
28*9bb18a98SKatherine Rasmussen
29*9bb18a98SKatherine Rasmussen  n = image_status(2, home)
30*9bb18a98SKatherine Rasmussen  n = image_status(2, league(1))
31*9bb18a98SKatherine Rasmussen  n = image_status(image=2, team=home)
32*9bb18a98SKatherine Rasmussen  n = image_status(team=home, image=2)
33*9bb18a98SKatherine Rasmussen
34*9bb18a98SKatherine Rasmussen  if (image_status(1) .eq. stat_failed_image .or. image_status(1) .eq. stat_stopped_image) then
35*9bb18a98SKatherine Rasmussen     error stop
36*9bb18a98SKatherine Rasmussen  else if (image_status(1) .eq. 0) then
37*9bb18a98SKatherine Rasmussen     continue
38*9bb18a98SKatherine Rasmussen  end if
39*9bb18a98SKatherine Rasmussen
40*9bb18a98SKatherine Rasmussen  !___ non-conforming statements ___
41*9bb18a98SKatherine Rasmussen
42*9bb18a98SKatherine Rasmussen  !ERROR: 'image=' argument for intrinsic 'image_status' must be a positive value, but is -1
43*9bb18a98SKatherine Rasmussen  n = image_status(-1)
44*9bb18a98SKatherine Rasmussen
45*9bb18a98SKatherine Rasmussen  !ERROR: 'image=' argument for intrinsic 'image_status' must be a positive value, but is 0
46*9bb18a98SKatherine Rasmussen  n = image_status(0)
47*9bb18a98SKatherine Rasmussen
48*9bb18a98SKatherine Rasmussen  !ERROR: 'image=' argument for intrinsic 'image_status' must be a positive value, but is -4
49*9bb18a98SKatherine Rasmussen  n = image_status(constant_negative)
50*9bb18a98SKatherine Rasmussen
51*9bb18a98SKatherine Rasmussen  !ERROR: 'image=' argument for intrinsic 'image_status' must be a positive value, but is 0
52*9bb18a98SKatherine Rasmussen  n = image_status(constant_zero)
53*9bb18a98SKatherine Rasmussen
54*9bb18a98SKatherine Rasmussen  !ERROR: 'team=' argument has unacceptable rank 1
55*9bb18a98SKatherine Rasmussen  n = image_status(1, team=league)
56*9bb18a98SKatherine Rasmussen
57*9bb18a98SKatherine Rasmussen  !ERROR: Actual argument for 'image=' has bad type 'REAL(4)'
58*9bb18a98SKatherine Rasmussen  n = image_status(3.4)
59*9bb18a98SKatherine Rasmussen
60*9bb18a98SKatherine Rasmussen  !ERROR: Actual argument for 'image=' has bad type 'LOGICAL(4)'
61*9bb18a98SKatherine Rasmussen  n = image_status(wrong_arg_type_logical)
62*9bb18a98SKatherine Rasmussen
63*9bb18a98SKatherine Rasmussen  !ERROR: Actual argument for 'image=' has bad type 'REAL(4)'
64*9bb18a98SKatherine Rasmussen  n = image_status(wrong_arg_type_real)
65*9bb18a98SKatherine Rasmussen
66*9bb18a98SKatherine Rasmussen  !ERROR: Actual argument for 'team=' has bad type 'INTEGER(4)'
67*9bb18a98SKatherine Rasmussen  n = image_status(1, not_team_type)
68*9bb18a98SKatherine Rasmussen
69*9bb18a98SKatherine Rasmussen  !ERROR: Actual argument for 'team=' has bad type 'INTEGER(4)'
70*9bb18a98SKatherine Rasmussen  n = image_status(1, 1)
71*9bb18a98SKatherine Rasmussen
72*9bb18a98SKatherine Rasmussen  !ERROR: Actual argument for 'image=' has bad type 'REAL(4)'
73*9bb18a98SKatherine Rasmussen  n = image_status(image=3.4)
74*9bb18a98SKatherine Rasmussen
75*9bb18a98SKatherine Rasmussen  !ERROR: Actual argument for 'team=' has bad type 'INTEGER(4)'
76*9bb18a98SKatherine Rasmussen  n = image_status(1, team=1)
77*9bb18a98SKatherine Rasmussen
78*9bb18a98SKatherine Rasmussen  !ERROR: too many actual arguments for intrinsic 'image_status'
79*9bb18a98SKatherine Rasmussen  n = image_status(1, home, 2)
80*9bb18a98SKatherine Rasmussen
81*9bb18a98SKatherine Rasmussen  !ERROR: repeated keyword argument to intrinsic 'image_status'
82*9bb18a98SKatherine Rasmussen  n = image_status(image=1, image=2)
83*9bb18a98SKatherine Rasmussen
84*9bb18a98SKatherine Rasmussen  !ERROR: repeated keyword argument to intrinsic 'image_status'
85*9bb18a98SKatherine Rasmussen  n = image_status(image=1, team=home, team=league(1))
86*9bb18a98SKatherine Rasmussen
87*9bb18a98SKatherine Rasmussen  !ERROR: unknown keyword argument to intrinsic 'image_status'
88*9bb18a98SKatherine Rasmussen  n = image_status(images=1)
89*9bb18a98SKatherine Rasmussen
90*9bb18a98SKatherine Rasmussen  !ERROR: unknown keyword argument to intrinsic 'image_status'
91*9bb18a98SKatherine Rasmussen  n = image_status(1, my_team=home)
92*9bb18a98SKatherine Rasmussen
93*9bb18a98SKatherine Rasmussen  !ERROR: 'image=' argument for intrinsic 'image_status' must contain all positive values
94*9bb18a98SKatherine Rasmussen  result_array = image_status(image=array_with_negative)
95*9bb18a98SKatherine Rasmussen
96*9bb18a98SKatherine Rasmussen  !ERROR: 'image=' argument for intrinsic 'image_status' must contain all positive values
97*9bb18a98SKatherine Rasmussen  result_array = image_status(image=[-2, 1])
98*9bb18a98SKatherine Rasmussen
99*9bb18a98SKatherine Rasmussen  !ERROR: 'image=' argument for intrinsic 'image_status' must contain all positive values
100*9bb18a98SKatherine Rasmussen  result_array = image_status(image=array_with_zero)
101*9bb18a98SKatherine Rasmussen
102*9bb18a98SKatherine Rasmussen  !ERROR: 'image=' argument for intrinsic 'image_status' must contain all positive values
103*9bb18a98SKatherine Rasmussen  result_array = image_status(image=[1, 0])
104*9bb18a98SKatherine Rasmussen
105*9bb18a98SKatherine Rasmussen  !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)
106*9bb18a98SKatherine Rasmussen  non_array_result = image_status(image=array)
107*9bb18a98SKatherine Rasmussen
108*9bb18a98SKatherine Rasmussen  !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches rank 1 array of INTEGER(4) and rank 2 array of INTEGER(4)
109*9bb18a98SKatherine Rasmussen  wrong_rank_result = image_status(array_2d)
110*9bb18a98SKatherine Rasmussen
111*9bb18a98SKatherine Rasmussen  !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types CHARACTER(KIND=1) and INTEGER(4)
112*9bb18a98SKatherine Rasmussen  wrong_result_type = image_status(1)
113*9bb18a98SKatherine Rasmussen
114*9bb18a98SKatherine Rasmussenend program test_image_status
115