Skip to content

Commit e8adf97

Browse files
committed
Skip clause verification when inside of context-selector
1 parent 2c6a741 commit e8adf97

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ class AssociatedLoopChecker {
214214
};
215215

216216
bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) {
217+
// Do not do clause checks while processing METADIRECTIVE.
218+
if (GetDirectiveNest(ContextSelectorNest) > 0) {
219+
return true;
220+
}
221+
217222
unsigned version{context_.langOptions().OpenMPVersion};
218223
DirectiveContext &dirCtx = GetContext();
219224
llvm::omp::Directive dir{dirCtx.directive};
@@ -4458,6 +4463,14 @@ void OmpStructureChecker::Enter(const parser::OmpClause::OmpxBare &x) {
44584463
}
44594464
}
44604465

4466+
void OmpStructureChecker::Enter(const parser::OmpContextSelector &ctxSel) {
4467+
EnterDirectiveNest(ContextSelectorNest);
4468+
}
4469+
4470+
void OmpStructureChecker::Leave(const parser::OmpContextSelector &) {
4471+
ExitDirectiveNest(ContextSelectorNest);
4472+
}
4473+
44614474
llvm::StringRef OmpStructureChecker::getClauseName(llvm::omp::Clause clause) {
44624475
return llvm::omp::getOpenMPClauseName(clause);
44634476
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ class OmpStructureChecker
150150
void Enter(const parser::OmpMetadirectiveDirective &);
151151
void Leave(const parser::OmpMetadirectiveDirective &);
152152

153+
void Enter(const parser::OmpContextSelector &);
154+
void Leave(const parser::OmpContextSelector &);
155+
153156
#define GEN_FLANG_CLAUSE_CHECK_ENTER
154157
#include "llvm/Frontend/OpenMP/OMP.inc"
155158

@@ -286,7 +289,8 @@ class OmpStructureChecker
286289
TargetBlockOnlyTeams,
287290
TargetNest,
288291
DeclarativeNest,
289-
LastType = DeclarativeNest,
292+
ContextSelectorNest,
293+
LastType = ContextSelectorNest,
290294
};
291295
int directiveNest_[LastType + 1] = {0};
292296

flang/test/Parser/OpenMP/metadirective.f90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ subroutine f30
8383
!PARSE-TREE: | | | OmpTraitSelector
8484
!PARSE-TREE: | | | | OmpTraitSelectorName -> Value = Atomic_Default_Mem_Order
8585
!PARSE-TREE: | | | | Properties
86-
!PARSE-TREE: | | | | | OmpTraitProperty -> OmpTraitPropertyName -> string = 'acq_rel'
86+
!PARSE-TREE: | | | | | OmpTraitProperty -> OmpClause -> AcqRel
8787
!PARSE-TREE: | | OmpDirectiveSpecification
8888
!PARSE-TREE: | | | llvm::omp::Directive = nothing
8989
!PARSE-TREE: | | | OmpClauseList ->
9090

9191
!UNPARSE: SUBROUTINE f30
92-
!UNPARSE: !$OMP METADIRECTIVE WHEN(IMPLEMENTATION={ATOMIC_DEFAULT_MEM_ORDER(acq_rel)}: &
92+
!UNPARSE: !$OMP METADIRECTIVE WHEN(IMPLEMENTATION={ATOMIC_DEFAULT_MEM_ORDER(ACQ_REL)}: &
9393
!UNPARSE: !$OMP&NOTHING)
9494
!UNPARSE: END SUBROUTINE
9595

@@ -194,3 +194,4 @@ subroutine f41
194194
!PARSE-TREE: | | OmpDirectiveSpecification
195195
!PARSE-TREE: | | | llvm::omp::Directive = nothing
196196
!PARSE-TREE: | | | OmpClauseList ->
197+
:qa

0 commit comments

Comments
 (0)