[LLVM] Fix Maintainers.md formatting (NFC)
[llvm-project.git] / flang / test / Semantics / image_index02.f90
blob1f296df2433c50159ae359f0fed985ebe714b2de
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Check for semantic errors in image_index() function references
3 ! based on the 16.9.107 section of the Fortran 2023 standard
5 program image_index_test
6 use iso_c_binding, only: c_int32_t
7 use iso_fortran_env, only: team_type
8 implicit none
10 integer n, array(1), non_coarray, scalar, team_num
11 integer scalar_coarray[*], array_coarray(1)[*], coarray_corank3[10, 0:9, 0:*], repeated_coarray[*]
12 integer subscripts_corank1(1), subscripts_corank3(3), repeated_sub(1), multi_rank_array(3,3)
13 integer, parameter :: const_subscripts_corank1(1) = [1]
14 logical non_integer_array(1)
15 type(team_type) :: home, league(2), wrong_result_type
17 !___ non-conforming statements ___
19 !ERROR: missing mandatory 'coarray=' argument
20 n = image_index()
22 !ERROR: missing mandatory 'sub=' argument
23 n = image_index(scalar_coarray)
25 !ERROR: 'sub=' argument has unacceptable rank 2
26 n = image_index(scalar_coarray, multi_rank_array)
28 !ERROR: The size of 'SUB=' (1) for intrinsic 'image_index' must be equal to the corank of 'COARRAY=' (3)
29 n = image_index(coarray_corank3, subscripts_corank1, league(1))
31 !ERROR: The size of 'SUB=' (1) for intrinsic 'image_index' must be equal to the corank of 'COARRAY=' (3)
32 n = image_index(coarray_corank3, const_subscripts_corank1, league(1))
34 !ERROR: The size of 'SUB=' (1) for intrinsic 'image_index' must be equal to the corank of 'COARRAY=' (3)
35 n = image_index(coarray_corank3, [1], league(1))
37 !ERROR: The size of 'SUB=' (6) for intrinsic 'image_index' must be equal to the corank of 'COARRAY=' (3)
38 n = image_index(coarray_corank3, [1,2,3,4,5,6])
40 !ERROR: missing mandatory 'coarray=' argument
41 n = image_index(sub=[1])
43 !ERROR: unknown keyword argument to intrinsic 'image_index'
44 n = image_index(team=home)
46 !ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'image_index'
47 n = image_index(non_coarray, [1])
49 !ERROR: Actual argument for 'sub=' has bad type 'LOGICAL(4)'
50 n = image_index(array_coarray, [.true.])
52 !ERROR: Actual argument for 'sub=' has bad type 'LOGICAL(4)'
53 n = image_index(array_coarray, non_integer_array)
55 !ERROR: 'sub=' argument has unacceptable rank 0
56 n = image_index(array_coarray, scalar)
58 !ERROR: unknown keyword argument to intrinsic 'image_index'
59 n = image_index(scalar_coarray, subscripts_corank1, team=league)
61 !ERROR: unknown keyword argument to intrinsic 'image_index'
62 n = image_index(scalar_coarray, [1], team=team_num)
64 !ERROR: too many actual arguments for intrinsic 'image_index'
65 n = image_index(array_coarray, [1], home, team_num)
67 !ERROR: too many actual arguments for intrinsic 'image_index'
68 n = image_index(array_coarray, [1], home, team_num)
70 !ERROR: unknown keyword argument to intrinsic 'image_index'
71 n = image_index(array_coarray, [1], team=home, team=league(1))
73 !ERROR: repeated keyword argument to intrinsic 'image_index'
74 n = image_index(coarray=scalar_coarray, sub=[1], coarray=repeated_coarray)
76 !ERROR: keyword argument to intrinsic 'image_index' was supplied positionally by an earlier actual argument
77 n = image_index(scalar_coarray, [1], coarray=repeated_coarray)
79 !ERROR: repeated keyword argument to intrinsic 'image_index'
80 n = image_index(scalar_coarray, sub=subscripts_corank1, sub=repeated_sub)
82 !ERROR: keyword argument to intrinsic 'image_index' was supplied positionally by an earlier actual argument
83 n = image_index(scalar_coarray, subscripts_corank1, sub=repeated_sub)
85 !ERROR: unknown keyword argument to intrinsic 'image_index'
86 n = image_index(scalar_coarray, [1], team_number=array)
88 !ERROR: unknown keyword argument to intrinsic 'image_index'
89 n = image_index(scalar_coarray, [1], team_number=home)
91 !ERROR: unknown keyword argument to intrinsic 'image_index'
92 n = image_index(array_coarray, [1], team=home, team_number=team_num)
94 !ERROR: unknown keyword argument to intrinsic 'image_index'
95 n = image_index(c=scalar_coarray, [1])
97 !ERROR: unknown keyword argument to intrinsic 'image_index'
98 n = image_index(scalar_coarray, subscripts=[1])
100 !ERROR: unknown keyword argument to intrinsic 'image_index'
101 n = image_index(scalar_coarray, [1], team_num=team_num)
103 !ERROR: unknown keyword argument to intrinsic 'image_index'
104 n = image_index(scalar_coarray, [1], teams=home)
106 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(team_type) and INTEGER(4)
107 wrong_result_type = image_index(scalar_coarray, subscripts_corank1)
109 end program image_index_test