xref: /llvm-project/flang/test/Semantics/event01b.f90 (revision 2625510ef8094457413661ef0ce2651844f584d2)
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! Some of the errors in this test would be hidden by the errors in
5! the test event01a.f90 if they were included in that file,
6! and are thus tested here.
7
8program test_event_post
9  use iso_fortran_env, only : event_type
10  implicit none
11
12  ! event_type variables must be coarrays
13  !ERROR: Variable 'non_coarray' with EVENT_TYPE or LOCK_TYPE must be a coarray
14  type(event_type) non_coarray
15
16  ! event_type potential object components must be nested in coarrays
17  type :: has_event
18    type(event_type) event
19  end type
20  type :: bad1
21    type(has_event) component
22  end type
23  type :: bad2
24    type(has_event), allocatable :: component
25  end type
26  type :: good1
27    type(has_event), pointer :: component
28  end type
29  type :: good2
30    type(has_event), allocatable :: component[:]
31  end type
32  !ERROR: Variable 'non_coarray_component1' with EVENT_TYPE or LOCK_TYPE potential component '%event' must be a coarray
33  type(has_event) non_coarray_component1
34  !ERROR: Variable 'non_coarray_component2' with EVENT_TYPE or LOCK_TYPE potential component '%component%event' must be a coarray
35  type(bad1) non_coarray_component2
36  !ERROR: Variable 'non_coarray_component3' with EVENT_TYPE or LOCK_TYPE potential component '%component%event' must be a coarray
37  type(bad2) non_coarray_component3
38  ! these are okay
39  type(has_event) ok_non_coarray_component1[*]
40  type(has_event), pointer :: ok_non_coarray_component2
41  type(bad1) :: ok_non_coarray_component3[*]
42  type(bad1), pointer :: ok_non_coarray_component4
43  type(bad2) :: ok_non_coarray_component5[*]
44  type(bad2), pointer :: ok_non_coarray_component6
45  type(good1) ok_non_coarray_component7
46  type(good2) ok_non_coarray_component8
47
48  type(event_type) concert[*], occurrences(2)[*]
49  integer non_event[*], sync_status, co_indexed_integer[*], superfluous_stat, non_scalar(1)
50  character(len=128) error_message, co_indexed_character[*], superfluous_errmsg
51  logical invalid_type
52
53  !___ non-standard-conforming statements ___
54
55  !______ invalid event-variable ____________________________
56
57  ! event-variable must be event_type
58  !ERROR: The event-variable must be of type EVENT_TYPE from module ISO_FORTRAN_ENV
59  event post(non_event)
60
61  !ERROR: Must be a scalar value, but is a rank-1 array
62  event post(occurrences)
63
64  !ERROR: Must be a scalar value, but is a rank-1 array
65  event post(occurrences[1])
66
67  !______ invalid sync-stat-lists: invalid stat= ____________
68
69  !ERROR: Must have INTEGER type, but is LOGICAL(4)
70  event post(concert, stat=invalid_type)
71
72  !ERROR: Must be a scalar value, but is a rank-1 array
73  event post(concert, stat=non_scalar)
74
75  !______ invalid sync-stat-lists: invalid errmsg= ____________
76
77  !ERROR: Must have CHARACTER type, but is LOGICAL(4)
78  event post(concert, errmsg=invalid_type)
79
80  !______ invalid sync-stat-lists: redundant sync-stat-list ____________
81
82  !ERROR: The stat-variable in a sync-stat-list may not be repeated
83  event post(concert, stat=sync_status, stat=superfluous_stat)
84
85  !ERROR: The stat-variable in a sync-stat-list may not be repeated
86  event post(concert, errmsg=error_message, stat=sync_status, stat=superfluous_stat)
87
88  !ERROR: The stat-variable in a sync-stat-list may not be repeated
89  event post(concert, stat=sync_status, errmsg=error_message, stat=superfluous_stat)
90
91  !ERROR: The stat-variable in a sync-stat-list may not be repeated
92  event post(concert, stat=sync_status, stat=superfluous_stat, errmsg=error_message)
93
94  !ERROR: The errmsg-variable in a sync-stat-list may not be repeated
95  event post(concert, errmsg=error_message, errmsg=superfluous_errmsg)
96
97  !ERROR: The errmsg-variable in a sync-stat-list may not be repeated
98  event post(concert, stat=sync_status, errmsg=error_message, errmsg=superfluous_errmsg)
99
100  !ERROR: The errmsg-variable in a sync-stat-list may not be repeated
101  event post(concert, errmsg=error_message, stat=sync_status, errmsg=superfluous_errmsg)
102
103  !ERROR: The errmsg-variable in a sync-stat-list may not be repeated
104  event post(concert, errmsg=error_message, errmsg=superfluous_errmsg, stat=sync_status)
105
106  !______ invalid sync-stat-lists: coindexed stat-variable - C1173____________
107
108  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
109  event post(concert, stat=co_indexed_integer[1])
110
111  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
112  event post(concert, errmsg=co_indexed_character[1])
113
114  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
115  event post(concert, stat=co_indexed_integer[1], errmsg=error_message)
116
117  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
118  event post(concert, stat=sync_status, errmsg=co_indexed_character[1])
119
120  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
121  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
122  event post(concert, stat=co_indexed_integer[1], errmsg=co_indexed_character[1])
123
124  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
125  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
126  event post(concert, errmsg=co_indexed_character[1], stat=co_indexed_integer[1])
127
128end program test_event_post
129