Skip to content

Commit e5e4288

Browse files
committed
Accept both "end atomic" and "endatomic"
1 parent 591e1d6 commit e5e4288

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ struct OmpEndDirectiveParser {
12391239
constexpr OmpEndDirectiveParser(llvm::omp::Directive dir) : dir_(dir) {}
12401240

12411241
std::optional<resultType> Parse(ParseState &state) const {
1242-
if ((startOmpLine >> "END"_id).Parse(state)) {
1242+
if ((startOmpLine >> "END"_sptok).Parse(state)) {
12431243
auto &&dirSpec{Parser<OmpDirectiveSpecification>{}.Parse(state)};
12441244
if (dirSpec && dirSpec->DirId() == dir_) {
12451245
return std::move(dirSpec);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
2+
!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s
3+
4+
subroutine f00
5+
integer :: x, v
6+
!$omp atomic read
7+
v = x
8+
!$omp end atomic
9+
end
10+
11+
!UNPARSE: SUBROUTINE f00
12+
!UNPARSE: INTEGER x, v
13+
!UNPARSE: !$OMP ATOMIC READ
14+
!UNPARSE: v=x
15+
!UNPARSE: !$OMP END ATOMIC
16+
!UNPARSE: END SUBROUTINE
17+
18+
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPAtomicConstruct
19+
!PARSE-TREE: | OmpDirectiveSpecification
20+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = atomic
21+
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Read
22+
!PARSE-TREE: | | Flags = None
23+
!PARSE-TREE: | Block
24+
!PARSE-TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'v=x'
25+
!PARSE-TREE: | | | Variable = 'v'
26+
!PARSE-TREE: | | | | Designator -> DataRef -> Name = 'v'
27+
!PARSE-TREE: | | | Expr = 'x'
28+
!PARSE-TREE: | | | | Designator -> DataRef -> Name = 'x'
29+
!PARSE-TREE: | OmpDirectiveSpecification
30+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = atomic
31+
!PARSE-TREE: | | OmpClauseList ->
32+
!PARSE-TREE: | | Flags = None
33+
34+
35+
subroutine f01
36+
integer :: x, v
37+
!$omp atomic read
38+
v = x
39+
!$omp endatomic
40+
end
41+
42+
!UNPARSE: SUBROUTINE f01
43+
!UNPARSE: INTEGER x, v
44+
!UNPARSE: !$OMP ATOMIC READ
45+
!UNPARSE: v=x
46+
!UNPARSE: !$OMP END ATOMIC
47+
!UNPARSE: END SUBROUTINE
48+
49+
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPAtomicConstruct
50+
!PARSE-TREE: | OmpDirectiveSpecification
51+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = atomic
52+
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Read
53+
!PARSE-TREE: | | Flags = None
54+
!PARSE-TREE: | Block
55+
!PARSE-TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'v=x'
56+
!PARSE-TREE: | | | Variable = 'v'
57+
!PARSE-TREE: | | | | Designator -> DataRef -> Name = 'v'
58+
!PARSE-TREE: | | | Expr = 'x'
59+
!PARSE-TREE: | | | | Designator -> DataRef -> Name = 'x'
60+
!PARSE-TREE: | OmpDirectiveSpecification
61+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = atomic
62+
!PARSE-TREE: | | OmpClauseList ->
63+
!PARSE-TREE: | | Flags = None

0 commit comments

Comments
 (0)