xref: /llvm-project/flang/test/Parser/OpenMP/sections.f90 (revision 3ad806a480b589e67b809fd4fb9c3e53f638a01f)
1! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s
2! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s
3
4subroutine openmp_sections(x, y)
5
6  integer, intent(inout)::x, y
7
8!==============================================================================
9! empty construct
10!==============================================================================
11!CHECK: !$omp sections
12!$omp sections
13  !CHECK: !$omp section
14!CHECK: !$omp end sections
15!$omp end sections
16
17!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct
18!PARSE-TREE: OmpBeginSectionsDirective
19!PARSE-TREE-NOT: ExecutionPartConstruct
20!PARSE-TREE: OmpEndSectionsDirective
21
22!==============================================================================
23! single section, without `!$omp section`
24!==============================================================================
25!CHECK: !$omp sections
26!$omp sections
27  !CHECK: !$omp section
28    !CHECK: CALL
29    call F1()
30!CHECK: !$omp end sections
31!$omp end sections
32
33!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct
34!PARSE-TREE:  OmpBeginSectionsDirective
35!PARSE-TREE:   OpenMPConstruct -> OpenMPSectionConstruct -> Block
36!PARSE-TREE:    CallStmt
37!PARSE-TREE-NOT: ExecutionPartConstruct
38!PARSE-TREE:  OmpEndSectionsDirective
39
40!==============================================================================
41! single section with `!$omp section`
42!==============================================================================
43!CHECK: !$omp sections
44!$omp sections
45  !CHECK: !$omp section
46  !$omp section
47    !CHECK: CALL F1
48    call F1
49!CHECK: !$omp end sections
50!$omp end sections
51
52!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct
53!PARSE-TREE:  OmpBeginSectionsDirective
54!PARSE-TREE:   OpenMPConstruct -> OpenMPSectionConstruct -> Block
55!PARSE-TREE:    CallStmt
56!PARSE-TREE-NOT: ExecutionPartConstruct
57!PARSE-TREE:  OmpEndSectionsDirective
58
59!==============================================================================
60! multiple sections
61!==============================================================================
62!CHECK: !$omp sections
63!$omp sections
64  !CHECK: !$omp section
65  !$omp section
66    !CHECK: CALL F1
67    call F1
68  !CHECK: !$omp section
69  !$omp section
70    !CHECK: CALL F2
71    call F2
72  !CHECK: !$omp section
73  !$omp section
74    !CHECK: CALL F3
75    call F3
76!CHECK: !$omp end sections
77!$omp end sections
78
79!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct
80!PARSE-TREE:  OmpBeginSectionsDirective
81!PARSE-TREE:   OpenMPConstruct -> OpenMPSectionConstruct -> Block
82!PARSE-TREE:    CallStmt
83!PARSE-TREE:   OpenMPConstruct -> OpenMPSectionConstruct -> Block
84!PARSE-TREE:    CallStmt
85!PARSE-TREE:   OpenMPConstruct -> OpenMPSectionConstruct -> Block
86!PARSE-TREE:    CallStmt
87!PARSE-TREE-NOT: ExecutionPartConstruct
88!PARSE-TREE:  OmpEndSectionsDirective
89
90!==============================================================================
91! multiple sections with clauses
92!==============================================================================
93!CHECK: !$omp sections PRIVATE(x) FIRSTPRIVATE(y)
94!$omp sections PRIVATE(x) FIRSTPRIVATE(y)
95  !CHECK: !$omp section
96  !$omp section
97    !CHECK: CALL F1
98    call F1
99  !CHECK: !$omp section
100  !$omp section
101    !CHECK: CALL F2
102    call F2
103  !CHECK: !$omp section
104  !$omp section
105    !CHECK: CALL F3
106    call F3
107!CHECK: !$omp end sections NOWAIT
108!$omp end sections NOWAIT
109
110!PARSE-TREE: OpenMPConstruct -> OpenMPSectionsConstruct
111!PARSE-TREE:  OmpBeginSectionsDirective
112!PARSE-TREE:   OpenMPConstruct -> OpenMPSectionConstruct -> Block
113!PARSE-TREE:    CallStmt
114!PARSE-TREE:   OpenMPConstruct -> OpenMPSectionConstruct -> Block
115!PARSE-TREE:    CallStmt
116!PARSE-TREE:   OpenMPConstruct -> OpenMPSectionConstruct -> Block
117!PARSE-TREE:    CallStmt
118!PARSE-TREE-NOT: ExecutionPartConstruct
119!PARSE-TREE:  OmpEndSectionsDirective
120
121END subroutine openmp_sections
122