xref: /llvm-project/flang/test/Semantics/synchronization02b.f90 (revision f770b1e9544967ce31b3c7eea3cfa87c00936ad2)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Check for semantic errors in sync images statements.
3! Some of the errors in this test would be hidden by the errors in
4! the test synchronization02a.f90 if they were included in that file,
5! and are thus tested here.
6
7program test_sync_images
8  implicit none
9
10  integer, parameter :: invalid_rank(*,*) = reshape([1], [1,1])
11  integer sync_status, non_scalar(2), superfluous_stat, coindexed_integer[*]
12  character(len=128) error_message, superfluous_errmsg, coindexed_character[*]
13  logical invalid_type
14
15  !___ non-standard-conforming statements ___
16
17  ! Image set shall not depend on the value of stat-variable
18  sync images(sync_status, stat=sync_status)
19
20  ! Image set shall not depend on the value of errmsg-variable
21  sync images(len(error_message), errmsg=error_message)
22
23  !ERROR: An image-set that is an int-expr must be a scalar or a rank-one array
24  sync images(invalid_rank)
25
26  !ERROR: Must have INTEGER type, but is LOGICAL(4)
27  sync images([1], stat=invalid_type)
28
29  !ERROR: Must be a scalar value, but is a rank-1 array
30  sync images(*, stat=non_scalar)
31
32  !ERROR: Must have CHARACTER type, but is LOGICAL(4)
33  sync images(1, errmsg=invalid_type)
34
35  !ERROR: The stat-variable in a sync-stat-list may not be repeated
36  sync images(1, stat=sync_status, stat=superfluous_stat)
37
38  !ERROR: The stat-variable in a sync-stat-list may not be repeated
39  sync images(1, stat=sync_status, errmsg=error_message, stat=superfluous_stat)
40
41  !ERROR: The errmsg-variable in a sync-stat-list may not be repeated
42  sync images([1], errmsg=error_message, errmsg=superfluous_errmsg)
43
44  !ERROR: The errmsg-variable in a sync-stat-list may not be repeated
45  sync images([1], stat=sync_status, errmsg=error_message, errmsg=superfluous_errmsg)
46
47  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
48  sync images(*, stat=coindexed_integer[1])
49
50  !ERROR: The stat-variable or errmsg-variable in a sync-stat-list may not be a coindexed object
51  sync images(1, errmsg=coindexed_character[1])
52
53end program test_sync_images
54