diff --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp --- a/flang/lib/Semantics/check-acc-structure.cpp +++ b/flang/lib/Semantics/check-acc-structure.cpp @@ -438,6 +438,15 @@ .str()), ContextDirectiveAsFortran()); } + if (GetContext().directive == llvm::acc::Directive::ACCD_declare) { + context_.Say(GetContext().clauseSource, + "The ZERO modifier is not allowed for the %s clause " + "on the %s directive"_err_en_US, + parser::ToUpperCaseLetters( + llvm::acc::getOpenACCClauseName(llvm::acc::Clause::ACCC_copyout) + .str()), + ContextDirectiveAsFortran()); + } } } diff --git a/flang/test/Semantics/OpenACC/acc-declare-validity.f90 b/flang/test/Semantics/OpenACC/acc-declare-validity.f90 --- a/flang/test/Semantics/OpenACC/acc-declare-validity.f90 +++ b/flang/test/Semantics/OpenACC/acc-declare-validity.f90 @@ -57,4 +57,10 @@ !$acc declare present(cc) end subroutine sub2 + subroutine sub3() + real :: aa(100) + !ERROR: The ZERO modifier is not allowed for the COPYOUT clause on the DECLARE directive + !$acc declare copyout(zero: aa) + end subroutine + end module openacc_declare_validity