xref: /llvm-project/flang/test/Semantics/failed_images.f90 (revision 2eeafa2022d2928e970cdd06b8dbb18973e2fa4e)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Check for semantic errors in failed_images() function calls
3
4program failed_images_test
5  use iso_fortran_env, only: team_type
6  use iso_c_binding, only: c_int32_t
7  implicit none
8
9  type(team_type) home, league(2)
10  integer n, i, array(1)
11  integer, allocatable :: failure(:)
12  integer, allocatable :: wrong_rank(:,:)
13  logical non_integer, non_team
14  character, allocatable :: wrong_result(:)
15
16  !___ standard-conforming statement with no optional arguments present ___
17  failure = failed_images()
18
19  !___ standard-conforming statements with optional team argument present ___
20  failure = failed_images(home)
21  failure = failed_images(team=home)
22  failure = failed_images(league(1))
23
24  !___ standard-conforming statements with optional kind argument present ___
25  failure = failed_images(kind=c_int32_t)
26
27  !___ standard-conforming statements with both optional arguments present ___
28  failure = failed_images(home, c_int32_t)
29  failure = failed_images(team=home, kind=c_int32_t)
30  failure = failed_images(kind=c_int32_t, team=home)
31
32  !___ non-conforming statements ___
33
34  !ERROR: Actual argument for 'team=' has bad type 'LOGICAL(4)'
35  failure = failed_images(non_team)
36
37  ! non-scalar team_type argument
38  !ERROR: 'team=' argument has unacceptable rank 1
39  failure = failed_images(league)
40
41  !ERROR: Actual argument for 'team=' has bad type 'INTEGER(4)'
42  failure = failed_images(team=-1)
43
44  !ERROR: Actual argument for 'team=' has bad type 'INTEGER(4)'
45  failure = failed_images(team=i, kind=c_int32_t)
46
47  !ERROR: Actual argument for 'team=' has bad type 'INTEGER(4)'
48  failure = failed_images(i, c_int32_t)
49
50  !ERROR: Actual argument for 'team=' has bad type 'INTEGER(4)'
51  failure = failed_images(c_int32_t)
52
53  ! non constant
54  !ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
55  failure = failed_images(kind=i)
56
57  ! non integer
58  !ERROR: Actual argument for 'kind=' has bad type 'LOGICAL(4)'
59  failure = failed_images(home, non_integer)
60  !ERROR: Actual argument for 'kind=' has bad type 'LOGICAL(4)'
61  failure = failed_images(kind=non_integer)
62
63  ! non-scalar
64  !ERROR: 'kind=' argument has unacceptable rank 1
65  failure = failed_images(kind=array)
66
67  !ERROR: too many actual arguments for intrinsic 'failed_images'
68  failure = failed_images(home, c_int32_t, 3)
69
70  !ERROR: Actual argument for 'team=' has bad type 'REAL(4)'
71  failure = failed_images(3.4)
72
73  !ERROR: unknown keyword argument to intrinsic 'failed_images'
74  failure = failed_images(kinds=c_int32_t)
75
76  !ERROR: unknown keyword argument to intrinsic 'failed_images'
77  failure = failed_images(home, kinds=c_int32_t)
78
79  !ERROR: unknown keyword argument to intrinsic 'failed_images'
80  failure = failed_images(my_team=home)
81
82  !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)
83  n = failed_images()
84
85  !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches rank 2 array of INTEGER(4) and rank 1 array of INTEGER(4)
86  wrong_rank = failed_images()
87
88  !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types CHARACTER(KIND=1) and INTEGER(4)
89  wrong_result = failed_images()
90
91end program failed_images_test
92