Skip to content

Commit 00ab44e

Browse files
authored
[flang][OpenMP] Add version checks for clauses (#110015)
If there is a clause that is allowed on a given directive in a later version of the OpenMP spec, report an error and provide the minimal spec version that allows the clause. The case where a clause is not allowed on a directive at all is already handled elsewhere.
1 parent 3b20a83 commit 00ab44e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+149
-102
lines changed

Diff for: flang/lib/Semantics/check-omp-structure.cpp

+65-28
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ namespace Fortran::semantics {
1616
// Use when clause falls under 'struct OmpClause' in 'parse-tree.h'.
1717
#define CHECK_SIMPLE_CLAUSE(X, Y) \
1818
void OmpStructureChecker::Enter(const parser::OmpClause::X &) { \
19-
CheckAllowed(llvm::omp::Clause::Y); \
19+
CheckAllowedClause(llvm::omp::Clause::Y); \
2020
}
2121

2222
#define CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(X, Y) \
2323
void OmpStructureChecker::Enter(const parser::OmpClause::X &c) { \
24-
CheckAllowed(llvm::omp::Clause::Y); \
24+
CheckAllowedClause(llvm::omp::Clause::Y); \
2525
RequiresConstantPositiveParameter(llvm::omp::Clause::Y, c.v); \
2626
}
2727

2828
#define CHECK_REQ_SCALAR_INT_CLAUSE(X, Y) \
2929
void OmpStructureChecker::Enter(const parser::OmpClause::X &c) { \
30-
CheckAllowed(llvm::omp::Clause::Y); \
30+
CheckAllowedClause(llvm::omp::Clause::Y); \
3131
RequiresPositiveParameter(llvm::omp::Clause::Y, c.v); \
3232
}
3333

3434
// Use when clause don't falls under 'struct OmpClause' in 'parse-tree.h'.
3535
#define CHECK_SIMPLE_PARSER_CLAUSE(X, Y) \
3636
void OmpStructureChecker::Enter(const parser::X &) { \
37-
CheckAllowed(llvm::omp::Y); \
37+
CheckAllowedClause(llvm::omp::Y); \
3838
}
3939

4040
// 'OmpWorkshareBlockChecker' is used to check the validity of the assignment
@@ -163,6 +163,43 @@ class AssociatedLoopChecker {
163163
std::map<std::string, std::int64_t> constructNamesAndLevels_;
164164
};
165165

166+
bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) {
167+
unsigned version{context_.langOptions().OpenMPVersion};
168+
DirectiveContext &dirCtx = GetContext();
169+
llvm::omp::Directive dir{dirCtx.directive};
170+
171+
if (!llvm::omp::isAllowedClauseForDirective(dir, clause, version)) {
172+
unsigned allowedInVersion{[&] {
173+
for (unsigned v : {45, 50, 51, 52, 60}) {
174+
if (v <= version) {
175+
continue;
176+
}
177+
if (llvm::omp::isAllowedClauseForDirective(dir, clause, v)) {
178+
return v;
179+
}
180+
}
181+
return 0u;
182+
}()};
183+
184+
// Only report it if there is a later version that allows it.
185+
// If it's not allowed at all, it will be reported by CheckAllowed.
186+
if (allowedInVersion != 0) {
187+
auto clauseName{parser::ToUpperCaseLetters(getClauseName(clause).str())};
188+
auto dirName{parser::ToUpperCaseLetters(getDirectiveName(dir).str())};
189+
190+
std::string thisVersion{
191+
std::to_string(version / 10) + "." + std::to_string(version % 10)};
192+
std::string goodVersion{std::to_string(allowedInVersion)};
193+
194+
context_.Say(dirCtx.clauseSource,
195+
"%s clause is not allowed on directive %s in OpenMP v%s, "
196+
"try -fopenmp-version=%d"_err_en_US,
197+
clauseName, dirName, thisVersion, allowedInVersion);
198+
}
199+
}
200+
return CheckAllowed(clause);
201+
}
202+
166203
bool OmpStructureChecker::IsCloselyNestedRegion(const OmpDirectiveSet &set) {
167204
// Definition of close nesting:
168205
//
@@ -1156,7 +1193,7 @@ void OmpStructureChecker::Leave(const parser::OpenMPDeclarativeAllocate &x) {
11561193
}
11571194

11581195
void OmpStructureChecker::Enter(const parser::OmpClause::Allocator &x) {
1159-
CheckAllowed(llvm::omp::Clause::OMPC_allocator);
1196+
CheckAllowedClause(llvm::omp::Clause::OMPC_allocator);
11601197
// Note: Predefined allocators are stored in ScalarExpr as numbers
11611198
// whereas custom allocators are stored as strings, so if the ScalarExpr
11621199
// actually has an int value, then it must be a predefined allocator
@@ -1165,7 +1202,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Allocator &x) {
11651202
}
11661203

11671204
void OmpStructureChecker::Enter(const parser::OmpClause::Allocate &x) {
1168-
CheckAllowed(llvm::omp::Clause::OMPC_allocate);
1205+
CheckAllowedClause(llvm::omp::Clause::OMPC_allocate);
11691206
if (const auto &modifier{
11701207
std::get<std::optional<parser::OmpAllocateClause::AllocateModifier>>(
11711208
x.v.t)}) {
@@ -2362,7 +2399,7 @@ CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Simdlen, OMPC_simdlen)
23622399
// Restrictions specific to each clause are implemented apart from the
23632400
// generalized restrictions.
23642401
void OmpStructureChecker::Enter(const parser::OmpClause::Reduction &x) {
2365-
CheckAllowed(llvm::omp::Clause::OMPC_reduction);
2402+
CheckAllowedClause(llvm::omp::Clause::OMPC_reduction);
23662403
if (CheckReductionOperators(x)) {
23672404
CheckReductionTypeList(x);
23682405
}
@@ -2686,7 +2723,7 @@ void OmpStructureChecker::CheckSharedBindingInOuterContext(
26862723
}
26872724

26882725
void OmpStructureChecker::Enter(const parser::OmpClause::Ordered &x) {
2689-
CheckAllowed(llvm::omp::Clause::OMPC_ordered);
2726+
CheckAllowedClause(llvm::omp::Clause::OMPC_ordered);
26902727
// the parameter of ordered clause is optional
26912728
if (const auto &expr{x.v}) {
26922729
RequiresConstantPositiveParameter(llvm::omp::Clause::OMPC_ordered, *expr);
@@ -2701,17 +2738,17 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Ordered &x) {
27012738
}
27022739

27032740
void OmpStructureChecker::Enter(const parser::OmpClause::Shared &x) {
2704-
CheckAllowed(llvm::omp::Clause::OMPC_shared);
2741+
CheckAllowedClause(llvm::omp::Clause::OMPC_shared);
27052742
CheckIsVarPartOfAnotherVar(GetContext().clauseSource, x.v, "SHARED");
27062743
}
27072744
void OmpStructureChecker::Enter(const parser::OmpClause::Private &x) {
2708-
CheckAllowed(llvm::omp::Clause::OMPC_private);
2745+
CheckAllowedClause(llvm::omp::Clause::OMPC_private);
27092746
CheckIsVarPartOfAnotherVar(GetContext().clauseSource, x.v, "PRIVATE");
27102747
CheckIntentInPointer(x.v, llvm::omp::Clause::OMPC_private);
27112748
}
27122749

27132750
void OmpStructureChecker::Enter(const parser::OmpClause::Nowait &x) {
2714-
CheckAllowed(llvm::omp::Clause::OMPC_nowait);
2751+
CheckAllowedClause(llvm::omp::Clause::OMPC_nowait);
27152752
if (llvm::omp::noWaitClauseNotAllowedSet.test(GetContext().directive)) {
27162753
context_.Say(GetContext().clauseSource,
27172754
"%s clause is not allowed on the OMP %s directive,"
@@ -2784,7 +2821,7 @@ void OmpStructureChecker::CheckIsVarPartOfAnotherVar(
27842821
}
27852822

27862823
void OmpStructureChecker::Enter(const parser::OmpClause::Firstprivate &x) {
2787-
CheckAllowed(llvm::omp::Clause::OMPC_firstprivate);
2824+
CheckAllowedClause(llvm::omp::Clause::OMPC_firstprivate);
27882825

27892826
CheckIsVarPartOfAnotherVar(GetContext().clauseSource, x.v, "FIRSTPRIVATE");
27902827
CheckIsLoopIvPartOfClause(llvmOmpClause::OMPC_firstprivate, x.v);
@@ -2871,7 +2908,7 @@ void OmpStructureChecker::Leave(const parser::OmpAtomic &) {
28712908
// Restrictions specific to each clause are implemented apart from the
28722909
// generalized restrictions.
28732910
void OmpStructureChecker::Enter(const parser::OmpClause::Aligned &x) {
2874-
CheckAllowed(llvm::omp::Clause::OMPC_aligned);
2911+
CheckAllowedClause(llvm::omp::Clause::OMPC_aligned);
28752912

28762913
if (const auto &expr{
28772914
std::get<std::optional<parser::ScalarIntConstantExpr>>(x.v.t)}) {
@@ -2880,7 +2917,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Aligned &x) {
28802917
// 2.8.1 TODO: list-item attribute check
28812918
}
28822919
void OmpStructureChecker::Enter(const parser::OmpClause::Defaultmap &x) {
2883-
CheckAllowed(llvm::omp::Clause::OMPC_defaultmap);
2920+
CheckAllowedClause(llvm::omp::Clause::OMPC_defaultmap);
28842921
using VariableCategory = parser::OmpDefaultmapClause::VariableCategory;
28852922
if (!std::get<std::optional<VariableCategory>>(x.v.t)) {
28862923
context_.Say(GetContext().clauseSource,
@@ -2889,7 +2926,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Defaultmap &x) {
28892926
}
28902927
}
28912928
void OmpStructureChecker::Enter(const parser::OmpClause::If &x) {
2892-
CheckAllowed(llvm::omp::Clause::OMPC_if);
2929+
CheckAllowedClause(llvm::omp::Clause::OMPC_if);
28932930
using dirNameModifier = parser::OmpIfClause::DirectiveNameModifier;
28942931
// TODO Check that, when multiple 'if' clauses are applied to a combined
28952932
// construct, at most one of them applies to each directive.
@@ -2925,7 +2962,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::If &x) {
29252962
}
29262963

29272964
void OmpStructureChecker::Enter(const parser::OmpClause::Linear &x) {
2928-
CheckAllowed(llvm::omp::Clause::OMPC_linear);
2965+
CheckAllowedClause(llvm::omp::Clause::OMPC_linear);
29292966

29302967
// 2.7 Loop Construct Restriction
29312968
if ((llvm::omp::allDoSet | llvm::omp::allSimdSet)
@@ -2959,7 +2996,7 @@ void OmpStructureChecker::CheckAllowedMapTypes(
29592996
}
29602997

29612998
void OmpStructureChecker::Enter(const parser::OmpClause::Map &x) {
2962-
CheckAllowed(llvm::omp::Clause::OMPC_map);
2999+
CheckAllowedClause(llvm::omp::Clause::OMPC_map);
29633000

29643001
if (const auto &maptype{std::get<std::optional<parser::OmpMapType>>(x.v.t)}) {
29653002
using Type = parser::OmpMapType::Type;
@@ -3005,7 +3042,7 @@ bool OmpStructureChecker::ScheduleModifierHasType(
30053042
return false;
30063043
}
30073044
void OmpStructureChecker::Enter(const parser::OmpClause::Schedule &x) {
3008-
CheckAllowed(llvm::omp::Clause::OMPC_schedule);
3045+
CheckAllowedClause(llvm::omp::Clause::OMPC_schedule);
30093046
const parser::OmpScheduleClause &scheduleClause = x.v;
30103047

30113048
// 2.7 Loop Construct Restriction
@@ -3041,7 +3078,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Schedule &x) {
30413078
}
30423079

30433080
void OmpStructureChecker::Enter(const parser::OmpClause::Device &x) {
3044-
CheckAllowed(llvm::omp::Clause::OMPC_device);
3081+
CheckAllowedClause(llvm::omp::Clause::OMPC_device);
30453082
const parser::OmpDeviceClause &deviceClause = x.v;
30463083
const auto &device{std::get<1>(deviceClause.t)};
30473084
RequiresPositiveParameter(
@@ -3060,7 +3097,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Device &x) {
30603097
}
30613098

30623099
void OmpStructureChecker::Enter(const parser::OmpClause::Depend &x) {
3063-
CheckAllowed(llvm::omp::Clause::OMPC_depend);
3100+
CheckAllowedClause(llvm::omp::Clause::OMPC_depend);
30643101
if ((std::holds_alternative<parser::OmpDependClause::Source>(x.v.u) ||
30653102
std::holds_alternative<parser::OmpDependClause::Sink>(x.v.u)) &&
30663103
GetContext().directive != llvm::omp::OMPD_ordered) {
@@ -3103,7 +3140,7 @@ void OmpStructureChecker::CheckCopyingPolymorphicAllocatable(
31033140
}
31043141

31053142
void OmpStructureChecker::Enter(const parser::OmpClause::Copyprivate &x) {
3106-
CheckAllowed(llvm::omp::Clause::OMPC_copyprivate);
3143+
CheckAllowedClause(llvm::omp::Clause::OMPC_copyprivate);
31073144
CheckIntentInPointer(x.v, llvm::omp::Clause::OMPC_copyprivate);
31083145
SymbolSourceMap currSymbols;
31093146
GetSymbolsInObjectList(x.v, currSymbols);
@@ -3121,7 +3158,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Copyprivate &x) {
31213158
}
31223159

31233160
void OmpStructureChecker::Enter(const parser::OmpClause::Lastprivate &x) {
3124-
CheckAllowed(llvm::omp::Clause::OMPC_lastprivate);
3161+
CheckAllowedClause(llvm::omp::Clause::OMPC_lastprivate);
31253162

31263163
CheckIsVarPartOfAnotherVar(GetContext().clauseSource, x.v, "LASTPRIVATE");
31273164

@@ -3145,7 +3182,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Lastprivate &x) {
31453182
}
31463183

31473184
void OmpStructureChecker::Enter(const parser::OmpClause::Copyin &x) {
3148-
CheckAllowed(llvm::omp::Clause::OMPC_copyin);
3185+
CheckAllowedClause(llvm::omp::Clause::OMPC_copyin);
31493186

31503187
SymbolSourceMap currSymbols;
31513188
GetSymbolsInObjectList(x.v, currSymbols);
@@ -3180,7 +3217,7 @@ void OmpStructureChecker::CheckStructureElement(
31803217

31813218
void OmpStructureChecker::Enter(const parser::OmpClause::UseDevicePtr &x) {
31823219
CheckStructureElement(x.v, llvm::omp::Clause::OMPC_use_device_ptr);
3183-
CheckAllowed(llvm::omp::Clause::OMPC_use_device_ptr);
3220+
CheckAllowedClause(llvm::omp::Clause::OMPC_use_device_ptr);
31843221
SymbolSourceMap currSymbols;
31853222
GetSymbolsInObjectList(x.v, currSymbols);
31863223
semantics::UnorderedSymbolSet listVars;
@@ -3213,7 +3250,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::UseDevicePtr &x) {
32133250

32143251
void OmpStructureChecker::Enter(const parser::OmpClause::UseDeviceAddr &x) {
32153252
CheckStructureElement(x.v, llvm::omp::Clause::OMPC_use_device_addr);
3216-
CheckAllowed(llvm::omp::Clause::OMPC_use_device_addr);
3253+
CheckAllowedClause(llvm::omp::Clause::OMPC_use_device_addr);
32173254
SymbolSourceMap currSymbols;
32183255
GetSymbolsInObjectList(x.v, currSymbols);
32193256
semantics::UnorderedSymbolSet listVars;
@@ -3238,7 +3275,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::UseDeviceAddr &x) {
32383275
}
32393276

32403277
void OmpStructureChecker::Enter(const parser::OmpClause::IsDevicePtr &x) {
3241-
CheckAllowed(llvm::omp::Clause::OMPC_is_device_ptr);
3278+
CheckAllowedClause(llvm::omp::Clause::OMPC_is_device_ptr);
32423279
SymbolSourceMap currSymbols;
32433280
GetSymbolsInObjectList(x.v, currSymbols);
32443281
semantics::UnorderedSymbolSet listVars;
@@ -3276,7 +3313,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause::IsDevicePtr &x) {
32763313
}
32773314

32783315
void OmpStructureChecker::Enter(const parser::OmpClause::HasDeviceAddr &x) {
3279-
CheckAllowed(llvm::omp::Clause::OMPC_has_device_addr);
3316+
CheckAllowedClause(llvm::omp::Clause::OMPC_has_device_addr);
32803317
SymbolSourceMap currSymbols;
32813318
GetSymbolsInObjectList(x.v, currSymbols);
32823319
semantics::UnorderedSymbolSet listVars;
@@ -3621,7 +3658,7 @@ void OmpStructureChecker::Enter(
36213658
}
36223659

36233660
void OmpStructureChecker::CheckAllowedRequiresClause(llvmOmpClause clause) {
3624-
CheckAllowed(clause);
3661+
CheckAllowedClause(clause);
36253662

36263663
if (clause != llvm::omp::Clause::OMPC_atomic_default_mem_order) {
36273664
// Check that it does not appear after a device construct

Diff for: flang/lib/Semantics/check-omp-structure.h

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class OmpStructureChecker
139139
}
140140

141141
private:
142+
bool CheckAllowedClause(llvmOmpClause clause);
142143
void CheckMultipleOccurrence(semantics::UnorderedSymbolSet &listVars,
143144
const std::list<parser::Name> &nameList, const parser::CharBlock &item,
144145
const std::string &clauseName);

Diff for: flang/test/Examples/omp-in-reduction-clause.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! REQUIRES: plugins, examples, shell
22

3-
! RUN: %flang_fc1 -load %llvmshlibdir/flangOmpReport.so -plugin flang-omp-report -fopenmp %s -o - | FileCheck %s
3+
! RUN: %flang_fc1 -load %llvmshlibdir/flangOmpReport.so -plugin flang-omp-report -fopenmp -fopenmp-version=50 %s -o - | FileCheck %s
44

55
! Check for IN_REDUCTION() clause on OpenMP constructs
66

Diff for: flang/test/Examples/omp-order-clause.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! REQUIRES: plugins, examples, shell
22

3-
! RUN: %flang_fc1 -load %llvmshlibdir/flangOmpReport.so -plugin flang-omp-report -fopenmp %s -o - | FileCheck %s
3+
! RUN: %flang_fc1 -load %llvmshlibdir/flangOmpReport.so -plugin flang-omp-report -fopenmp -fopenmp-version=50 %s -o - | FileCheck %s
44

55
! Check for ORDER([order-modifier :]concurrent) clause on OpenMP constructs
66

Diff for: flang/test/Lower/OpenMP/atomic-capture.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
! This test checks the lowering of atomic capture
44

5-
! RUN: bbc %openmp_flags -emit-hlfir %s -o - | FileCheck %s
6-
! RUN: %flang_fc1 -emit-hlfir %openmp_flags %s -o - | FileCheck %s
5+
! RUN: bbc %openmp_flags -fopenmp-version=50 -emit-hlfir %s -o - | FileCheck %s
6+
! RUN: %flang_fc1 -emit-hlfir %openmp_flags -fopenmp-version=50 %s -o - | FileCheck %s
77

88

99
program OmpAtomicCapture

Diff for: flang/test/Lower/OpenMP/atomic-read.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! REQUIRES: openmp_runtime
22

3-
! RUN: bbc %openmp_flags -emit-hlfir %s -o - | FileCheck %s
3+
! RUN: bbc %openmp_flags -fopenmp-version=50 -emit-hlfir %s -o - | FileCheck %s
44

55
! This test checks the lowering of atomic read
66

Diff for: flang/test/Lower/OpenMP/atomic-update.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
! REQUIRES: openmp_runtime
22

33
! This test checks lowering of atomic and atomic update constructs
4-
! RUN: bbc %openmp_flags -emit-hlfir %s -o - | FileCheck %s
5-
! RUN: %flang_fc1 -emit-hlfir %openmp_flags %s -o - | FileCheck %s
4+
! RUN: bbc %openmp_flags -fopenmp-version=50 -emit-hlfir %s -o - | FileCheck %s
5+
! RUN: %flang_fc1 -emit-hlfir %openmp_flags -fopenmp-version=50 %s -o - | FileCheck %s
66

77
program OmpAtomicUpdate
88
use omp_lib

Diff for: flang/test/Lower/OpenMP/atomic-write.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! REQUIRES: openmp_runtime
22

3-
! RUN: bbc %openmp_flags -emit-hlfir %s -o - | FileCheck %s
3+
! RUN: bbc %openmp_flags -fopenmp-version=50 -emit-hlfir %s -o - | FileCheck %s
44

55
! This test checks the lowering of atomic write
66

Diff for: flang/test/Lower/OpenMP/declare-target-data.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2-
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s
2+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -fopenmp-is-target-device %s -o - | FileCheck %s
33

44
module test_0
55
implicit none

Diff for: flang/test/Lower/OpenMP/declare-target-deferred-marking.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes ALL,HOST
2-
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s --check-prefixes ALL
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s --check-prefixes ALL,HOST
2+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -fopenmp-is-device %s -o - | FileCheck %s --check-prefixes ALL
33

44
program main
55
use, intrinsic :: iso_c_binding

Diff for: flang/test/Lower/OpenMP/declare-target-func-and-subr.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes ALL,HOST
2-
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s --check-prefixes ALL,DEVICE
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s --check-prefixes ALL,HOST
2+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -fopenmp-is-device %s -o - | FileCheck %s --check-prefixes ALL,DEVICE
33

44
! Check specification valid forms of declare target with functions
55
! utilising device_type and to clauses as well as the default

Diff for: flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap-enter.f90

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2-
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
3-
!RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
4-
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s
2+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
3+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s
4+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=52 -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
55

66
! CHECK-LABEL: func.func @_QPimplicitly_captured_twice
77
! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (enter)>{{.*}}}

Diff for: flang/test/Lower/OpenMP/declare-target-implicit-func-and-subr-cap.f90

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2-
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
3-
!RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
4-
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 %s -o - | FileCheck %s
2+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
3+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=50 %s -o - | FileCheck %s
4+
!RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=50 -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefix=DEVICE
55

66
! CHECK-LABEL: func.func @_QPimplicitly_captured
77
! CHECK-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}}}

0 commit comments

Comments
 (0)