xref: /llvm-project/flang/test/Semantics/num_images02.f90 (revision 473d780692ee06683cdd82999bf31fcbea065061)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Check for semantic errors in num_images() function calls
3
4program num_images_with_team_type
5  use iso_fortran_env, only : team_type
6  implicit none
7
8  type(team_type) home, league(2)
9  integer n
10  integer :: standard_initial_value = -1
11  integer coindexed[*]
12  integer array(1)
13
14  !___ standard-conforming statement with no optional arguments present ___
15  n = num_images()
16
17  !___ standard-conforming statements with team_number argument present ___
18  n = num_images(-1)
19  n = num_images(team_number = -1)
20  n = num_images(team_number = standard_initial_value)
21  n = num_images(standard_initial_value)
22  n = num_images(coindexed[1])
23
24  !___ standard-conforming statements with team_type argument present ___
25  n = num_images(home)
26  n = num_images(team=home)
27
28  !___ non-conforming statements ___
29
30  ! non-scalar integer argument
31  !ERROR: unknown keyword argument to intrinsic 'num_images'
32  n = num_images(team_number=array)
33
34  ! non-scalar team_type argument
35  !ERROR: unknown keyword argument to intrinsic 'num_images'
36  n = num_images(team=league)
37
38  ! incorrectly typed argument
39  !ERROR: too many actual arguments for intrinsic 'num_images'
40  n = num_images(3.4)
41
42  !ERROR: too many actual arguments for intrinsic 'num_images'
43  n = num_images(1, -1)
44
45  !ERROR: too many actual arguments for intrinsic 'num_images'
46  n = num_images(home, standard_initial_value)
47
48  ! keyword argument with incorrect type
49  !ERROR: unknown keyword argument to intrinsic 'num_images'
50  n = num_images(team_number=1.1)
51
52  ! incorrect keyword argument name but valid type (type number)
53  !ERROR: unknown keyword argument to intrinsic 'num_images'
54  n = num_images(team_num=-1)
55
56  ! incorrect keyword argument name but valid type (team_type)
57  !ERROR: unknown keyword argument to intrinsic 'num_images'
58  n = num_images(my_team=home)
59
60  ! correct keyword argument name but mismatched type
61  !ERROR: unknown keyword argument to intrinsic 'num_images'
62  n = num_images(team=-1)
63
64  ! correct keyword argument name but mismatched type
65  !ERROR: unknown keyword argument to intrinsic 'num_images'
66  n = num_images(team_number=home)
67
68end program num_images_with_team_type
69