1! RUN: %python %S/test_errors.py %s %flang_fc1
2! This test checks for semantic errors in event post statements based on the
3! statement specification in section 11.6.7 of the Fortran 2018 standard.
4
5program test_event_post
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 non_event[*], sync_status, co_indexed_integer[*], superfluous_stat, non_scalar(1)
14  character(len=128) error_message, co_indexed_character[*], superfluous_errmsg
15  logical invalid_type
16
17  !___ standard-conforming statement ___
18
19  event post(concert)
20  event post(concert[1])
21  event post(occurrences(1))
22  event post(occurrences(1)[1])
23  event post(concert, stat=sync_status)
24  event post(concert,                   errmsg=error_message)
25  event post(concert, stat=sync_status, errmsg=error_message)
26
27  !___ non-standard-conforming statement ___
28
29  !______ invalid event-variable ____________________________
30
31  ! event-variable must be event_type
32  event post(non_event)
33
34  ! event-variable must be a coarray
35  event post(non_coarray)
36
37  ! event-variable must be a scalar variable
38  event post(occurrences)
39
40  ! event-variable must be a scalar variable
41  event post(occurrences[1])
42
43  ! event-variable has an unknown keyword argument
44  !ERROR: expected ')'
45  event post(event=concert)
46
47  !______ invalid sync-stat-lists: invalid stat= ____________
48
49  ! Invalid stat-variable keyword
50  !ERROR: expected ')'
51  event post(concert, status=sync_status)
52
53  ! Stat-variable must an integer scalar
54  event post(concert, stat=invalid_type)
55
56  ! Stat-variable must an integer scalar
57  event post(concert, stat=non_scalar)
58
59  ! Invalid sync-stat-list: missing stat-variable
60  !ERROR: expected ')'
61  event post(concert, stat)
62
63  ! Invalid sync-stat-list: missing 'stat='
64  !ERROR: expected ')'
65  event post(concert, sync_status)
66
67  !______ invalid sync-stat-lists: invalid errmsg= ____________
68
69  ! Invalid errmsg-variable keyword
70  !ERROR: expected ')'
71  event post(concert, errormsg=error_message)
72
73  ! Invalid errmsg-variable argument typing
74  event post(concert, errmsg=invalid_type)
75
76  ! Invalid sync-stat-list: missing 'errmsg='
77  !ERROR: expected ')'
78  event post(concert, error_message)
79
80  ! Invalid sync-stat-list: missing errmsg-variable
81  !ERROR: expected ')'
82  event post(concert, errmsg)
83
84  !______ invalid event-variable: redundant event-variable ____________
85
86  ! Too many arguments
87  !ERROR: expected ')'
88  event post(concert, occurrences(1))
89
90  ! Too many arguments
91  !ERROR: expected ')'
92  event post(concert, occurrences(1), stat=sync_status, errmsg=error_message)
93
94  !______ invalid sync-stat-lists: redundant sync-stat-list ____________
95
96  ! No specifier shall appear more than once in a given sync-stat-list
97  event post(concert, stat=sync_status, stat=superfluous_stat)
98
99  ! No specifier shall appear more than once in a given sync-stat-list
100  event post(concert, errmsg=error_message, errmsg=superfluous_errmsg)
101
102  !______ invalid sync-stat-lists: coindexed stat-variable ____________
103
104  ! Check constraint C1173 from the Fortran 2018 standard
105  event post(concert, stat=co_indexed_integer[1])
106
107  ! Check constraint C1173 from the Fortran 2018 standard
108  event post(concert, errmsg=co_indexed_character[1])
109
110end program test_event_post
111