xref: /llvm-project/flang/test/Semantics/event02a.f90 (revision 21dceb3ca67cdc0e05b95e1d229bd01a8cd29f60)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! This test checks for semantic errors in event wait statements based on the
3! statement specification in section 11.6.8 of the Fortran 2018 standard.
4
5program test_event_wait
6  use iso_fortran_env, only : event_type
7  implicit none
8
9  ! event_type variables must be coarrays
10  type(event_type) non_coarray
11
12  type(event_type) concert[*], occurrences(2)[*]
13  integer threshold, indexed(1), non_event[*], sync_status, co_indexed_integer[*], superfluous_stat, non_scalar(1)
14  character(len=128) error_message, non_scalar_char(1), co_indexed_character[*], superfluous_errmsg
15  logical invalid_type
16
17  !_______________________ standard-conforming statements ___________________________
18
19  event wait(concert)
20  event wait(occurrences(1))
21  event wait(concert, until_count=threshold)
22  event wait(concert, until_count=indexed(1))
23  event wait(concert, until_count=co_indexed_integer[1])
24  event wait(concert,                        stat=sync_status)
25  event wait(concert, until_count=threshold, stat=sync_status)
26  event wait(concert,                                          errmsg=error_message)
27  event wait(concert, until_count=threshold,                   errmsg=error_message)
28  event wait(concert,                        stat=sync_status, errmsg=error_message)
29  event wait(concert, until_count=threshold, stat=sync_status, errmsg=error_message)
30
31  !____________________ non-standard-conforming statements __________________________
32
33  !_________________________ invalid event-variable ________________________________
34
35  ! event-variable has an unknown expression
36  !ERROR: expected ')'
37  event wait(event=concert)
38
39  !_____________ invalid event-wait-spec-lists: invalid until-spec _________________
40
41  ! Invalid until-spec keyword
42  !ERROR: expected ')'
43  event wait(concert, until_amount=threshold)
44
45  ! Invalid until-spec: missing until-spec variable
46  !ERROR: expected ')'
47  event wait(concert, until_count)
48
49  ! Invalid until-spec: missing 'until_count='
50  !ERROR: expected ')'
51  event wait(concert, threshold)
52
53  !_________________ invalid sync-stat-lists: invalid stat= ________________________
54
55  ! Invalid stat-variable keyword
56  !ERROR: expected ')'
57  event wait(concert, status=sync_status)
58
59  ! Invalid sync-stat-list: missing stat-variable
60  !ERROR: expected ')'
61  event wait(concert, stat)
62
63  ! Invalid sync-stat-list: missing 'stat='
64  !ERROR: expected ')'
65  event wait(concert, sync_status)
66
67  !________________ invalid sync-stat-lists: invalid errmsg= _______________________
68
69  ! Invalid errmsg-variable keyword
70  !ERROR: expected ')'
71  event wait(concert, errormsg=error_message)
72
73  ! Invalid sync-stat-list: missing 'errmsg='
74  !ERROR: expected ')'
75  event wait(concert, error_message)
76
77  ! Invalid sync-stat-list: missing errmsg-variable
78  !ERROR: expected ')'
79  event wait(concert, errmsg)
80
81  !______________ invalid event-variable: redundant event-variable _________________
82
83  !ERROR: expected ')'
84  event wait(concert, occurrences(1))
85
86  !ERROR: expected ')'
87  event wait(concert, occurrences(1), stat=sync_status, errmsg=error_message)
88
89end program test_event_wait
90