llvm::acc::Directive currentDirective_;
};
+bool AccStructureChecker::CheckAllowedModifier(llvm::acc::Clause clause) {
+ if (GetContext().directive == llvm::acc::ACCD_enter_data ||
+ GetContext().directive == llvm::acc::ACCD_exit_data) {
+ context_.Say(GetContext().clauseSource,
+ "Modifier is not allowed for the %s clause "
+ "on the %s directive"_err_en_US,
+ parser::ToUpperCaseLetters(getClauseName(clause).str()),
+ ContextDirectiveAsFortran());
+ return true;
+ }
+ return false;
+}
+
void AccStructureChecker::Enter(const parser::AccClause &x) {
SetContextClause(x);
}
const auto &modifierClause{c.v};
if (const auto &modifier{
std::get<std::optional<parser::AccDataModifier>>(modifierClause.t)}) {
+ if (CheckAllowedModifier(llvm::acc::Clause::ACCC_copyin))
+ return;
if (modifier->v != parser::AccDataModifier::Modifier::ReadOnly) {
context_.Say(GetContext().clauseSource,
"Only the READONLY modifier is allowed for the %s clause "
const auto &modifierClause{c.v};
if (const auto &modifier{
std::get<std::optional<parser::AccDataModifier>>(modifierClause.t)}) {
+ if (CheckAllowedModifier(llvm::acc::Clause::ACCC_copyout))
+ return;
if (modifier->v != parser::AccDataModifier::Modifier::Zero) {
context_.Say(GetContext().clauseSource,
"Only the ZERO modifier is allowed for the %s clause "
const llvm::acc::Directive directive,
const parser::CharBlock &directiveSource) const;
+ bool CheckAllowedModifier(llvm::acc::Clause clause);
+
llvm::StringRef getClauseName(llvm::acc::Clause clause) override;
llvm::StringRef getDirectiveName(llvm::acc::Directive directive) override;
};
!ERROR: At least one of ATTACH, COPYIN, CREATE clause must appear on the ENTER DATA directive
!$acc enter data
- !ERROR: Only the READONLY modifier is allowed for the COPYIN clause on the ENTER DATA directive
+ !ERROR: Modifier is not allowed for the COPYIN clause on the ENTER DATA directive
!$acc enter data copyin(zero: i)
+ !ERROR: Modifier is not allowed for the COPYOUT clause on the EXIT DATA directive
+ !$acc exit data copyout(zero: i)
+
!ERROR: Only the ZERO modifier is allowed for the CREATE clause on the ENTER DATA directive
!$acc enter data create(readonly: i)