diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index c6c4fdf8a8198..606014276e7ca 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -2575,8 +2575,8 @@ void OmpStructureChecker::CheckCancellationNest( } break; default: - // This should have been diagnosed by this point. - llvm_unreachable("Unexpected directive"); + // This is diagnosed later. + return; } if (!eligibleCancellation) { context_.Say(source, @@ -2614,8 +2614,8 @@ void OmpStructureChecker::CheckCancellationNest( parser::ToUpperCaseLetters(typeName.str())); break; default: - // This should have been diagnosed by this point. - llvm_unreachable("Unexpected directive"); + // This is diagnosed later. + return; } } } diff --git a/flang/test/Semantics/OpenMP/cancel-bad-cancel-type.f90 b/flang/test/Semantics/OpenMP/cancel-bad-cancel-type.f90 new file mode 100644 index 0000000000000..ea5e7be23e2f9 --- /dev/null +++ b/flang/test/Semantics/OpenMP/cancel-bad-cancel-type.f90 @@ -0,0 +1,6 @@ +!RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags + +program test +!ERROR: PARALLEL DO is not a cancellable construct +!$omp cancel parallel do +end