Skip to content

Commit bab121f

Browse files
committed
Argument to GRAPH_RESET is optional
1 parent 9d7db38 commit bab121f

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

flang/include/flang/Parser/parse-tree.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4441,9 +4441,10 @@ struct OmpGraphIdClause {
44414441
// Ref: [6.0:438-439]
44424442
//
44434443
// graph_reset-clause ->
4444-
// GRAPH_RESET(graph-reset-expression) // since 6.0
4444+
// GRAPH_RESET[(graph-reset-expression)] // since 6.0
44454445
struct OmpGraphResetClause {
4446-
WRAPPER_CLASS_BOILERPLATE(OmpGraphResetClause, common::Indirection<Expr>);
4446+
WRAPPER_CLASS_BOILERPLATE(
4447+
OmpGraphResetClause, std::optional<common::Indirection<Expr>>);
44474448
};
44484449

44494450
// Ref: [5.0:234-242], [5.1:266-275], [5.2:299], [6.0:472-473]

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,9 @@ TYPE_PARSER( //
11081108
parenthesized(Parser<OmpGrainsizeClause>{}))) ||
11091109
"GRAPH_ID" >> construct<OmpClause>(construct<OmpClause::GraphId>(
11101110
parenthesized(Parser<OmpGraphIdClause>{}))) ||
1111-
"GRAPH_RESET" >> construct<OmpClause>(construct<OmpClause::GraphReset>(
1112-
parenthesized(Parser<OmpGraphResetClause>{}))) ||
1111+
"GRAPH_RESET" >>
1112+
construct<OmpClause>(construct<OmpClause::GraphReset>(
1113+
maybe(parenthesized(Parser<OmpGraphResetClause>{})))) ||
11131114
"HAS_DEVICE_ADDR" >>
11141115
construct<OmpClause>(construct<OmpClause::HasDeviceAddr>(
11151116
parenthesized(Parser<OmpObjectList>{}))) ||

flang/test/Parser/OpenMP/taskgraph.f90

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,25 @@ subroutine f01(x, y)
7171
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = taskgraph
7272
!PARSE-TREE: | | OmpClauseList ->
7373
!PARSE-TREE: | | Flags = None
74+
75+
76+
subroutine f02
77+
!$omp taskgraph graph_reset
78+
!$omp end taskgraph
79+
end
80+
81+
!UNPARSE: SUBROUTINE f02
82+
!UNPARSE: !$OMP TASKGRAPH GRAPH_RESET
83+
!UNPARSE: !$OMP END TASKGRAPH
84+
!UNPARSE: END SUBROUTINE
85+
86+
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct
87+
!PARSE-TREE: | OmpBeginDirective
88+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = taskgraph
89+
!PARSE-TREE: | | OmpClauseList -> OmpClause -> GraphReset ->
90+
!PARSE-TREE: | | Flags = None
91+
!PARSE-TREE: | Block
92+
!PARSE-TREE: | OmpEndDirective
93+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = taskgraph
94+
!PARSE-TREE: | | OmpClauseList ->
95+
!PARSE-TREE: | | Flags = None

llvm/include/llvm/Frontend/OpenMP/OMP.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def OMPC_GraphId : Clause<[Spelling<"graph_id">]> {
231231
}
232232
def OMPC_GraphReset : Clause<[Spelling<"graph_reset">]> {
233233
let flangClass = "OmpGraphResetClause";
234+
let isValueOptional = true;
234235
}
235236
def OMPC_HasDeviceAddr : Clause<[Spelling<"has_device_addr">]> {
236237
let clangClass = "OMPHasDeviceAddrClause";

0 commit comments

Comments
 (0)