Skip to content

[flang][openacc] Issue an error when TBP are used in data clause #71444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
const parser::Name &, const Symbol &, Symbol::Flag);
void AllowOnlyArrayAndSubArray(const parser::AccObjectList &objectList);
void DoNotAllowAssumedSizedArray(const parser::AccObjectList &objectList);
void AllowOnlyVariable(const parser::AccObject &object);
void EnsureAllocatableOrPointer(
const llvm::acc::Clause clause, const parser::AccObjectList &objectList);
void AddRoutineInfoToSymbol(
Expand Down Expand Up @@ -1117,6 +1118,25 @@ void AccAttributeVisitor::DoNotAllowAssumedSizedArray(
}
}

void AccAttributeVisitor::AllowOnlyVariable(const parser::AccObject &object) {
common::visit(
common::visitors{
[&](const parser::Designator &designator) {
const auto &name{GetLastName(designator)};
if (name.symbol && !semantics::IsVariableName(*name.symbol)) {
context_.Say(designator.source,
"Only variables are allowed in data clauses on the %s "
"directive"_err_en_US,
parser::ToUpperCaseLetters(
llvm::acc::getOpenACCDirectiveName(GetContext().directive)
.str()));
}
},
[&](const auto &name) {},
},
object.u);
}

bool AccAttributeVisitor::Pre(const parser::OpenACCCacheConstruct &x) {
const auto &verbatim{std::get<parser::Verbatim>(x.t)};
PushContext(verbatim.source, llvm::acc::Directive::ACCD_cache);
Expand Down Expand Up @@ -1281,6 +1301,7 @@ Symbol *AccAttributeVisitor::ResolveAccCommonBlockName(
void AccAttributeVisitor::ResolveAccObjectList(
const parser::AccObjectList &accObjectList, Symbol::Flag accFlag) {
for (const auto &accObject : accObjectList.v) {
AllowOnlyVariable(accObject);
ResolveAccObject(accObject, accFlag);
}
}
Expand Down
23 changes: 23 additions & 0 deletions flang/test/Semantics/OpenACC/acc-data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,26 @@ program openacc_data_validity
!$acc end data

end program openacc_data_validity

module mod1
type :: t1
integer :: a
contains
procedure :: t1_proc
end type

contains


subroutine t1_proc(this)
class(t1) :: this
end subroutine

subroutine sub4(t)
type(t1) :: t

!ERROR: Only variables are allowed in data clauses on the DATA directive
!$acc data copy(t%t1_proc)
!$acc end data
end subroutine
end module