[flang][OpenMP] Make OmpDirectiveNameModifier a distrinct type (#150768)
It was an alias for OmpDirectiveName, which could cause confusion in parse-tree visitors: a visitor for OmpDirectiveNameModifier could be executed for an OmpDirectiveName node, leading to unexpected results.
This commit is contained in:
parent
67273393b1
commit
6ffcfc5a8a
@ -3469,6 +3469,12 @@ WRAPPER_CLASS(PauseStmt, std::optional<StopCode>);
|
||||
|
||||
// --- Common definitions
|
||||
|
||||
#define INHERITED_WRAPPER_CLASS_BOILERPLATE(classname, basename) \
|
||||
BOILERPLATE(classname); \
|
||||
using basename::basename; \
|
||||
classname(basename &&base) : basename(std::move(base)) {} \
|
||||
using WrapperTrait = std::true_type
|
||||
|
||||
struct OmpClause;
|
||||
struct OmpDirectiveSpecification;
|
||||
|
||||
@ -3476,6 +3482,7 @@ struct OmpDirectiveName {
|
||||
// No boilerplates: this class should be copyable, movable, etc.
|
||||
constexpr OmpDirectiveName() = default;
|
||||
constexpr OmpDirectiveName(const OmpDirectiveName &) = default;
|
||||
constexpr OmpDirectiveName(llvm::omp::Directive x) : v(x) {}
|
||||
// Construct from an already parsed text. Use Verbatim for this because
|
||||
// Verbatim's source corresponds to an actual source location.
|
||||
// This allows "construct<OmpDirectiveName>(Verbatim("<name>"))".
|
||||
@ -3848,7 +3855,10 @@ struct OmpDeviceModifier {
|
||||
// [*] The IF clause is allowed on CANCEL in OpenMP 4.5, but only without
|
||||
// the directive-name-modifier. For the sake of uniformity CANCEL can be
|
||||
// considered a valid value in 4.5 as well.
|
||||
using OmpDirectiveNameModifier = OmpDirectiveName;
|
||||
struct OmpDirectiveNameModifier : public OmpDirectiveName {
|
||||
INHERITED_WRAPPER_CLASS_BOILERPLATE(
|
||||
OmpDirectiveNameModifier, OmpDirectiveName);
|
||||
};
|
||||
|
||||
// Ref: [5.1:205-209], [5.2:166-168]
|
||||
//
|
||||
|
@ -466,6 +466,8 @@ TYPE_PARSER(construct<OmpDeviceModifier>(
|
||||
"ANCESTOR" >> pure(OmpDeviceModifier::Value::Ancestor) ||
|
||||
"DEVICE_NUM" >> pure(OmpDeviceModifier::Value::Device_Num)))
|
||||
|
||||
TYPE_PARSER(construct<OmpDirectiveNameModifier>(OmpDirectiveNameParser{}))
|
||||
|
||||
TYPE_PARSER(construct<OmpExpectation>( //
|
||||
"PRESENT" >> pure(OmpExpectation::Value::Present)))
|
||||
|
||||
@ -609,7 +611,8 @@ TYPE_PARSER(sourced(construct<OmpFromClause::Modifier>(
|
||||
TYPE_PARSER(sourced(
|
||||
construct<OmpGrainsizeClause::Modifier>(Parser<OmpPrescriptiveness>{})))
|
||||
|
||||
TYPE_PARSER(sourced(construct<OmpIfClause::Modifier>(OmpDirectiveNameParser{})))
|
||||
TYPE_PARSER(sourced(
|
||||
construct<OmpIfClause::Modifier>(Parser<OmpDirectiveNameModifier>{})))
|
||||
|
||||
TYPE_PARSER(sourced(
|
||||
construct<OmpInitClause::Modifier>(
|
||||
|
@ -31,13 +31,13 @@ end
|
||||
! CHECK-NEXT: - clause: read
|
||||
! CHECK-NEXT: details: ''
|
||||
! CHECK-NEXT: - clause: seq_cst
|
||||
! CHECK-NEXT: details: 'name_modifier=atomic;'
|
||||
! CHECK-NEXT: details: ''
|
||||
! CHECK-NEXT:- file: '{{[^"]*}}omp-atomic.f90'
|
||||
! CHECK-NEXT: line: 12
|
||||
! CHECK-NEXT: construct: atomic
|
||||
! CHECK-NEXT: clauses:
|
||||
! CHECK-NEXT: - clause: seq_cst
|
||||
! CHECK-NEXT: details: 'name_modifier=atomic;'
|
||||
! CHECK-NEXT: details: ''
|
||||
! CHECK-NEXT: - clause: write
|
||||
! CHECK-NEXT: details: ''
|
||||
! CHECK-NEXT:- file: '{{[^"]*}}omp-atomic.f90'
|
||||
@ -45,7 +45,7 @@ end
|
||||
! CHECK-NEXT: construct: atomic
|
||||
! CHECK-NEXT: clauses:
|
||||
! CHECK-NEXT: - clause: capture
|
||||
! CHECK-NEXT: details: 'name_modifier=atomic;name_modifier=atomic;'
|
||||
! CHECK-NEXT: details: ''
|
||||
! CHECK-NEXT: - clause: seq_cst
|
||||
! CHECK-NEXT: details: ''
|
||||
! CHECK-NEXT:- file: '{{[^"]*}}omp-atomic.f90'
|
||||
|
Loading…
x
Reference in New Issue
Block a user