Skip to content

Commit 17bfec5

Browse files
authored
[flang][OpenMP] Use OmpDirectiveSpecification in ASSUMES (#160591)
1 parent e25be77 commit 17bfec5

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

flang/include/flang/Parser/openmp-utils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ struct ConstructId {
3939
}
4040

4141
MAKE_CONSTR_ID(OpenMPDeclarativeAllocate, D::OMPD_allocate);
42-
MAKE_CONSTR_ID(OpenMPDeclarativeAssumes, D::OMPD_assumes);
4342
MAKE_CONSTR_ID(OpenMPDeclareReductionConstruct, D::OMPD_declare_reduction);
4443
MAKE_CONSTR_ID(OpenMPExecutableAllocate, D::OMPD_allocate);
4544
MAKE_CONSTR_ID(OpenMPRequiresConstruct, D::OMPD_requires);
@@ -94,7 +93,6 @@ struct DirectiveNameScope {
9493
if constexpr (std::is_base_of_v<OmpBlockConstruct, T>) {
9594
return std::get<OmpBeginDirective>(x.t).DirName();
9695
} else if constexpr (std::is_same_v<T, OpenMPDeclarativeAllocate> ||
97-
std::is_same_v<T, OpenMPDeclarativeAssumes> ||
9896
std::is_same_v<T, OpenMPDeclareReductionConstruct> ||
9997
std::is_same_v<T, OpenMPExecutableAllocate> ||
10098
std::is_same_v<T, OpenMPRequiresConstruct>) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4877,8 +4877,8 @@ struct OpenMPUtilityConstruct {
48774877
// ASSUMES absent-clause | contains-clause | holds-clause | no-openmp-clause |
48784878
// no-openmp-routines-clause | no-parallelism-clause
48794879
struct OpenMPDeclarativeAssumes {
4880-
TUPLE_CLASS_BOILERPLATE(OpenMPDeclarativeAssumes);
4881-
std::tuple<Verbatim, OmpClauseList> t;
4880+
WRAPPER_CLASS_BOILERPLATE(
4881+
OpenMPDeclarativeAssumes, OmpDirectiveSpecification);
48824882
CharBlock source;
48834883
};
48844884

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,9 @@ TYPE_PARSER(
18531853

18541854
// Assumes Construct
18551855
TYPE_PARSER(sourced(construct<OpenMPDeclarativeAssumes>(
1856-
verbatim("ASSUMES"_tok), Parser<OmpClauseList>{})))
1856+
predicated(OmpDirectiveNameParser{},
1857+
IsDirective(llvm::omp::Directive::OMPD_assumes)) >=
1858+
Parser<OmpDirectiveSpecification>{})))
18571859

18581860
// Declarative constructs
18591861
TYPE_PARSER(

flang/lib/Parser/unparse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,8 +2558,8 @@ class UnparseVisitor {
25582558

25592559
void Unparse(const OpenMPDeclarativeAssumes &x) {
25602560
BeginOpenMP();
2561-
Word("!$OMP ASSUMES ");
2562-
Walk(std::get<OmpClauseList>(x.t));
2561+
Word("!$OMP ");
2562+
Walk(x.v);
25632563
Put("\n");
25642564
EndOpenMP();
25652565
}

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,6 @@ template <typename Checker> struct DirectiveSpellingVisitor {
620620
checker_(GetDirName(x.t).source, Directive::OMPD_allocators);
621621
return false;
622622
}
623-
bool Pre(const parser::OpenMPDeclarativeAssumes &x) {
624-
checker_(std::get<parser::Verbatim>(x.t).source, Directive::OMPD_assumes);
625-
return false;
626-
}
627623
bool Pre(const parser::OpenMPGroupprivate &x) {
628624
checker_(x.v.DirName().source, Directive::OMPD_groupprivate);
629625
return false;

flang/test/Parser/OpenMP/assumption.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ program p
141141
end program p
142142

143143
!UNPARSE: PROGRAM p
144-
!UNPARSE: !$OMP ASSUMES NO_OPENMP
144+
!UNPARSE: !$OMP ASSUMES NO_OPENMP
145145
!UNPARSE: END PROGRAM p
146146

147-
!PARSE-TREE: OpenMPDeclarativeConstruct -> OpenMPDeclarativeAssumes
148-
!PARSE-TREE: | Verbatim
147+
!PARSE-TREE: OpenMPDeclarativeConstruct -> OpenMPDeclarativeAssumes -> OmpDirectiveSpecification
148+
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = assumes
149149
!PARSE-TREE: | OmpClauseList -> OmpClause -> NoOpenmp
150+
!PARSE-TREE: | Flags = None
151+
!PARSE-TREE: ImplicitPart ->

0 commit comments

Comments
 (0)