Skip to content

Commit 5f1a66a

Browse files
kparzyszivanradanov
authored andcommitted
Only accept ompx_bare on a combined "TARGET TEAMS" construct
1 parent d5c951e commit 5f1a66a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,6 +2433,7 @@ CHECK_SIMPLE_CLAUSE(CancellationConstructType, OMPC_cancellation_construct_type)
24332433
CHECK_SIMPLE_CLAUSE(Doacross, OMPC_doacross)
24342434
CHECK_SIMPLE_CLAUSE(OmpxAttribute, OMPC_ompx_attribute)
24352435
CHECK_SIMPLE_CLAUSE(OmpxBare, OMPC_ompx_bare)
2436+
CHECK_SIMPLE_CLAUSE(Enter, OMPC_enter)
24362437
CHECK_SIMPLE_CLAUSE(Fail, OMPC_fail)
24372438
CHECK_SIMPLE_CLAUSE(Weak, OMPC_weak)
24382439

@@ -3439,6 +3440,17 @@ void OmpStructureChecker::Enter(const parser::OmpClause::To &x) {
34393440
}
34403441
}
34413442

3443+
void OmpStructureChecker::Enter(const parser::OmpClause::OmpxBare &x) {
3444+
// Don't call CheckAllowedClause, because it allows "ompx_bare" on
3445+
// a non-combined "target" directive (for reasons of splitting combined
3446+
// directives). In source code it's only allowed on "target teams".
3447+
if (GetContext().directive != llvm::omp::Directive::OMPD_target_teams) {
3448+
context_.Say(GetContext().clauseSource,
3449+
"%s clause is only allowed on combined TARGET TEAMS"_err_en_US,
3450+
parser::ToUpperCaseLetters(getClauseName(llvm::omp::OMPC_ompx_bare)));
3451+
}
3452+
}
3453+
34423454
llvm::StringRef OmpStructureChecker::getClauseName(llvm::omp::Clause clause) {
34433455
return llvm::omp::getOpenMPClauseName(clause);
34443456
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=51
2+
3+
subroutine test1
4+
!ERROR: OMPX_BARE clause is only allowed on combined TARGET TEAMS
5+
!$omp target ompx_bare
6+
!$omp end target
7+
end
8+
9+
subroutine test2
10+
!$omp target
11+
!ERROR: OMPX_BARE clause is only allowed on combined TARGET TEAMS
12+
!$omp teams ompx_bare
13+
!$omp end teams
14+
!$omp end target
15+
end
16+
17+
subroutine test3
18+
!No errors
19+
!$omp target teams ompx_bare
20+
!$omp end target teams
21+
end

0 commit comments

Comments
 (0)