1! RUN: %python %S/test_errors.py %s %flang_fc1
2! XFAIL: *
3! Check for semantic errors in sync images statements
4
5program test_sync_images
6  implicit none
7
8  integer, parameter :: invalid_rank(*,*) = reshape([1], [1,1])
9  integer sync_status, non_scalar(2), superfluous_stat, coindexed_integer[*], me
10  character(len=128) error_message, superfluous_errmsg, coindexed_character[*]
11  logical invalid_type
12
13  !___ standard-conforming statement ___
14
15  sync images(*, stat=sync_status, errmsg=error_message)
16  sync images(*, stat=sync_status                      )
17  sync images(*,                   errmsg=error_message)
18  sync images(*                                        )
19
20  sync images(me,   stat=sync_status, errmsg=error_message)
21  sync images(me+1, stat=sync_status, errmsg=error_message)
22  sync images(1,    stat=sync_status, errmsg=error_message)
23  sync images(1,    stat=sync_status                      )
24  sync images(1,                      errmsg=error_message)
25  sync images(1                                           )
26
27  sync images([1],  stat=sync_status, errmsg=error_message)
28  sync images([1],  stat=sync_status                      )
29  sync images([1],                    errmsg=error_message)
30  sync images([1]                                         )
31
32  !___ non-standard-conforming statement ___
33
34  !______ invalid image sets ______
35
36  ! Image set shall not depend on the value of stat-variable
37  !ERROR: TBD
38  sync images(sync_status, stat=sync_status)
39
40  ! Image set shall not depend on the value of errmsg-variable
41  !ERROR: TBD
42  sync images(len(error_message), errmsg=error_message)
43
44  ! Image set shall be a scalar or rank-1 array
45  !ERROR: TBD
46  sync images(invalid_rank)
47
48  !______ invalid sync-stat-lists: invalid stat= ____________
49
50  ! Invalid sync-stat-list keyword
51  !ERROR: expected ')'
52  sync images(1, status=sync_status)
53
54  !ERROR: TBD
55  sync images([1], stat=invalid_type)
56
57  ! Stat-variable must an integer scalar
58  !ERROR: TBD
59  sync images(*, stat=non_scalar)
60
61  ! Invalid sync-stat-list: missing stat-variable
62  !ERROR: expected ')'
63  sync images(1, stat)
64
65  ! Invalid sync-stat-list: missing 'stat='
66  !ERROR: expected ')'
67  sync images([1], sync_status)
68
69  !______ invalid sync-stat-lists: invalid errmsg= ____________
70
71  ! Invalid errmsg-variable keyword
72  !ERROR: expected ')'
73  sync images(*, errormsg=error_message)
74
75  !ERROR: TBD
76  sync images(1, errmsg=invalid_type)
77
78  ! Invalid sync-stat-list: missing 'errmsg='
79  !ERROR: expected ')'
80  sync images([1], error_message)
81
82  ! Invalid sync-stat-list: missing errmsg-variable
83  !ERROR: expected ')'
84  sync images(*, errmsg)
85
86  !______ invalid sync-stat-lists: redundant sync-stat-list ____________
87
88  ! No specifier shall appear more than once in a given sync-stat-list
89  !ERROR: to be determined
90  sync images(1, stat=sync_status, stat=superfluous_stat)
91
92  ! No specifier shall appear more than once in a given sync-stat-list
93  !ERROR: to be determined
94  sync images([1], errmsg=error_message, errmsg=superfluous_errmsg)
95
96  !______ invalid sync-stat-lists: coindexed stat-variable ____________
97
98  ! Check constraint C1173 from the Fortran 2018 standard
99  !ERROR: to be determined
100  sync images(*, stat=coindexed_integer[1])
101
102  ! Check constraint C1173 from the Fortran 2018 standard
103  !ERROR: to be determined
104  sync images(1, errmsg=coindexed_character[1])
105
106end program test_sync_images
107