Skip to content

Conversation

@tblah
Copy link
Contributor

@tblah tblah commented May 20, 2025

Fixes #133685

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp flang:semantics labels May 20, 2025
@llvmbot
Copy link
Member

llvmbot commented May 20, 2025

@llvm/pr-subscribers-flang-openmp

Author: Tom Eccles (tblah)

Changes

Fixes #133685


Full diff: https://github.com/llvm/llvm-project/pull/140798.diff

2 Files Affected:

  • (modified) flang/lib/Semantics/check-omp-structure.cpp (+4-4)
  • (added) flang/test/Semantics/OpenMP/cancel-bad-cancel-type.f90 (+6)
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

@llvmbot
Copy link
Member

llvmbot commented May 20, 2025

@llvm/pr-subscribers-flang-semantics

Author: Tom Eccles (tblah)

Changes

Fixes #133685


Full diff: https://github.com/llvm/llvm-project/pull/140798.diff

2 Files Affected:

  • (modified) flang/lib/Semantics/check-omp-structure.cpp (+4-4)
  • (added) flang/test/Semantics/OpenMP/cancel-bad-cancel-type.f90 (+6)
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

Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG.

@tblah tblah merged commit f054aa2 into llvm:main May 21, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:openmp flang:semantics flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flang][OpenMP] only assertion-enabled flang can reach llvm_unreachable (cancel directive)

3 participants