Skip to content

Commit 8d386c6

Browse files
authored
[Frontend][OpenMP] Reduction modifier must be applied somewhere (#92160)
Detect the case when a reduction modifier ends up not being applied after construct decomposition, treat it as an error. This fixes a regression in the gfortran test suite after PR90098.
1 parent 4ec4a8e commit 8d386c6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
!Remove the --crash below once we can diagnose the issue more gracefully.
2+
!RUN: not --crash %flang_fc1 -fopenmp -emit-hlfir -o - %s
3+
4+
! Check that we reject the "task" reduction modifier on the "simd" directive.
5+
6+
subroutine fred(x)
7+
integer, intent(inout) :: x
8+
9+
!$omp simd reduction(task, +:x)
10+
do i = 1, 100
11+
x = foo(i)
12+
enddo
13+
!$omp end simd
14+
end

llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,8 @@ bool ConstructDecompositionT<C, H>::applyClause(
935935
// Apply clause without modifier.
936936
leaf.clauses.push_back(unmodified);
937937
}
938-
applied = true;
938+
// The modifier must be applied to some construct.
939+
applied = effectiveApplied;
939940
}
940941

941942
if (!applied)

0 commit comments

Comments
 (0)