Skip to content
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
6 changes: 6 additions & 0 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
return false;
}

bool Pre(const parser::AccClause::Reduction &x) {
const auto &objectList{std::get<parser::AccObjectList>(x.v.t)};
ResolveAccObjectList(objectList, Symbol::Flag::AccReduction);
return false;
}

void Post(const parser::Name &);

private:
Expand Down
14 changes: 12 additions & 2 deletions flang/test/Semantics/OpenACC/acc-reduction-validity.f90
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,23 @@ program openacc_reduction_validity
end program

subroutine sum()
! ERROR: 'sum' is already declared in this scoping unit
!ERROR: 'sum' is already declared in this scoping unit
integer :: i,sum
sum = 0
!$acc parallel
!$acc parallel
!ERROR: Only variables are allowed in data clauses on the LOOP directive
!$acc loop independent gang reduction(+:sum)
do i=1,10
sum = sum + i
enddo
!$acc end parallel
end subroutine

subroutine reduce()
integer :: red = 0, ii
!$acc parallel loop default(none) reduction(+:red)
do ii = 1, 10
red = red + ii
end do
!$acc end parallel
end subroutine