Skip to content

Commit 69aa451

Browse files
kparzysztblah
authored andcommitted
[flang][OpenMP] Semantic checks for context selectors (llvm#123243)
This implements checks of the validity of context set selectors and trait selectors, plus the types of trait properties. Clause properties are also validated, but not name or extension properties. --------- Co-authored-by: Tom Eccles <tom.eccles@arm.com>
1 parent 7bcc523 commit 69aa451

12 files changed

+743
-9
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -3572,6 +3572,7 @@ struct OmpTraitProperty {
35723572
// Trait-set-selectors:
35733573
// [D]evice, [T]arget_device, [C]onstruct, [I]mplementation, [U]ser.
35743574
struct OmpTraitSelectorName {
3575+
std::string ToString() const;
35753576
CharBlock source;
35763577
UNION_CLASS_BOILERPLATE(OmpTraitSelectorName);
35773578
ENUM_CLASS(Value, Arch, Atomic_Default_Mem_Order, Condition, Device_Num,
@@ -3596,6 +3597,7 @@ struct OmpTraitSelector {
35963597
// CONSTRUCT | DEVICE | IMPLEMENTATION | USER | // since 5.0
35973598
// TARGET_DEVICE // since 5.1
35983599
struct OmpTraitSetSelectorName {
3600+
std::string ToString() const;
35993601
CharBlock source;
36003602
ENUM_CLASS(Value, Construct, Device, Implementation, Target_Device, User)
36013603
WRAPPER_CLASS_BOILERPLATE(OmpTraitSetSelectorName, Value);

flang/include/flang/Semantics/openmp-modifiers.h

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ DECLARE_DESCRIPTOR(parser::OmpAlignModifier);
7272
DECLARE_DESCRIPTOR(parser::OmpAllocatorComplexModifier);
7373
DECLARE_DESCRIPTOR(parser::OmpAllocatorSimpleModifier);
7474
DECLARE_DESCRIPTOR(parser::OmpChunkModifier);
75+
DECLARE_DESCRIPTOR(parser::OmpContextSelector);
7576
DECLARE_DESCRIPTOR(parser::OmpDependenceType);
7677
DECLARE_DESCRIPTOR(parser::OmpDeviceModifier);
7778
DECLARE_DESCRIPTOR(parser::OmpDirectiveNameModifier);

flang/lib/Parser/parse-tree.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,26 @@ OmpTaskDependenceType::Value OmpDependClause::TaskDep::GetTaskDepType() const {
281281
}
282282
}
283283

284+
std::string OmpTraitSelectorName::ToString() const {
285+
return common::visit( //
286+
common::visitors{
287+
[&](Value v) { //
288+
return std::string(EnumToString(v));
289+
},
290+
[&](llvm::omp::Directive d) {
291+
return llvm::omp::getOpenMPDirectiveName(d).str();
292+
},
293+
[&](const std::string &s) { //
294+
return s;
295+
},
296+
},
297+
u);
298+
}
299+
300+
std::string OmpTraitSetSelectorName::ToString() const {
301+
return std::string(EnumToString(v));
302+
}
303+
284304
} // namespace Fortran::parser
285305

286306
template <typename C> static llvm::omp::Clause getClauseIdForClass(C &&) {

0 commit comments

Comments
 (0)