Skip to content

Commit 109df33

Browse files
committed
[flang][OpenMP] Semantic checks for context selectors
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.
1 parent 205a760 commit 109df33

File tree

12 files changed

+743
-9
lines changed

12 files changed

+743
-9
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,6 +3569,7 @@ struct OmpTraitProperty {
35693569
// Trait-set-selectors:
35703570
// [D]evice, [T]arget_device, [C]onstruct, [I]mplementation, [U]ser.
35713571
struct OmpTraitSelectorName {
3572+
std::string ToString() const;
35723573
CharBlock source;
35733574
UNION_CLASS_BOILERPLATE(OmpTraitSelectorName);
35743575
ENUM_CLASS(Value, Arch, Atomic_Default_Mem_Order, Condition, Device_Num,
@@ -3593,6 +3594,7 @@ struct OmpTraitSelector {
35933594
// CONSTRUCT | DEVICE | IMPLEMENTATION | USER | // since 5.0
35943595
// TARGET_DEVICE // since 5.1
35953596
struct OmpTraitSetSelectorName {
3597+
std::string ToString() const;
35963598
CharBlock source;
35973599
ENUM_CLASS(Value, Construct, Device, Implementation, Target_Device, User)
35983600
WRAPPER_CLASS_BOILERPLATE(OmpTraitSetSelectorName, Value);

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 20 additions & 0 deletions
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)