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
40 changes: 21 additions & 19 deletions flang/lib/Semantics/check-acc-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,26 +674,28 @@ void AccStructureChecker::Enter(const parser::AccClause::Reduction &reduction) {
common::visitors{
[&](const parser::Designator &designator) {
if (const auto *name = getDesignatorNameIfDataRef(designator)) {
const auto *type{name->symbol->GetType()};
if (type->IsNumeric(TypeCategory::Integer) &&
!reductionIntegerSet.test(op.v)) {
context_.Say(GetContext().clauseSource,
"reduction operator not supported for integer type"_err_en_US);
} else if (type->IsNumeric(TypeCategory::Real) &&
!reductionRealSet.test(op.v)) {
context_.Say(GetContext().clauseSource,
"reduction operator not supported for real type"_err_en_US);
} else if (type->IsNumeric(TypeCategory::Complex) &&
!reductionComplexSet.test(op.v)) {
context_.Say(GetContext().clauseSource,
"reduction operator not supported for complex type"_err_en_US);
} else if (type->category() ==
Fortran::semantics::DeclTypeSpec::Category::Logical &&
!reductionLogicalSet.test(op.v)) {
context_.Say(GetContext().clauseSource,
"reduction operator not supported for logical type"_err_en_US);
if (name->symbol) {
const auto *type{name->symbol->GetType()};
if (type->IsNumeric(TypeCategory::Integer) &&
!reductionIntegerSet.test(op.v)) {
context_.Say(GetContext().clauseSource,
"reduction operator not supported for integer type"_err_en_US);
} else if (type->IsNumeric(TypeCategory::Real) &&
!reductionRealSet.test(op.v)) {
context_.Say(GetContext().clauseSource,
"reduction operator not supported for real type"_err_en_US);
} else if (type->IsNumeric(TypeCategory::Complex) &&
!reductionComplexSet.test(op.v)) {
context_.Say(GetContext().clauseSource,
"reduction operator not supported for complex type"_err_en_US);
} else if (type->category() ==
Fortran::semantics::DeclTypeSpec::Category::Logical &&
!reductionLogicalSet.test(op.v)) {
context_.Say(GetContext().clauseSource,
"reduction operator not supported for logical type"_err_en_US);
}
// TODO: check composite type.
}
// TODO: check composite type.
}
},
[&](const Fortran::parser::Name &name) {
Expand Down
5 changes: 5 additions & 0 deletions flang/test/Semantics/OpenACC/acc-reduction-validity.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
! Check OpenACC reduction validity.

program openacc_reduction_validity
implicit none

integer :: i
real :: r
Expand Down Expand Up @@ -168,5 +169,9 @@ program openacc_reduction_validity
!$acc parallel reduction(ieor:l)
!$acc end parallel

!ERROR: No explicit type declared for 'xyz'
!$acc parallel reduction(+:xyz)
!$acc end parallel


end program
Loading