diff --git a/flang/test/Lower/OpenMP/invalid-reduction-modifier.f90 b/flang/test/Lower/OpenMP/invalid-reduction-modifier.f90 new file mode 100644 index 0000000000000..817c5b731c62f --- /dev/null +++ b/flang/test/Lower/OpenMP/invalid-reduction-modifier.f90 @@ -0,0 +1,14 @@ +!Remove the --crash below once we can diagnose the issue more gracefully. +!RUN: not --crash %flang_fc1 -fopenmp -emit-hlfir -o - %s + +! Check that we reject the "task" reduction modifier on the "simd" directive. + +subroutine fred(x) + integer, intent(inout) :: x + + !$omp simd reduction(task, +:x) + do i = 1, 100 + x = foo(i) + enddo + !$omp end simd +end diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h index 5f12c62b832fc..e5fcc493ea590 100644 --- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h +++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h @@ -930,7 +930,8 @@ bool ConstructDecompositionT::applyClause( // Apply clause without modifier. leaf.clauses.push_back(unmodified); } - applied = true; + // The modifier must be applied to some construct. + applied = effectiveApplied; } if (!applied)