diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 257c4696de403..14d526a71f458 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -922,6 +922,7 @@ OpenMP Support an invalid expression. (#GH139073) - Fixed a crashing bug with ``omp simd collapse`` if the argument to ``collapse`` was an invalid expression. (#GH138493) +- Fixed a crashing bug with a malformed ``cancel`` directive. (#GH139360) - Fixed a crashing bug with ``omp distribute dist_schedule`` if the argument to ``dist_schedule`` was not strictly positive. (#GH139266) diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 2508bf5795900..234c26e979ded 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2487,7 +2487,7 @@ StmtResult Parser::ParseOpenMPExecutableDirective( } else if (DKind == OMPD_cancellation_point || DKind == OMPD_cancel) { CancelRegion = parseOpenMPDirectiveKind(*this); if (Tok.isNot(tok::annot_pragma_openmp_end)) - ConsumeToken(); + ConsumeAnyToken(); } if (isOpenMPLoopDirective(DKind)) diff --git a/clang/test/OpenMP/cancel_messages.cpp b/clang/test/OpenMP/cancel_messages.cpp index 0c96beecc04b0..1391578cb0977 100644 --- a/clang/test/OpenMP/cancel_messages.cpp +++ b/clang/test/OpenMP/cancel_messages.cpp @@ -93,3 +93,8 @@ label1 : { return 0; } +namespace GH139360 { +void f(){ +#pragma omp cancel( // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}} +} +} // namesapce GH139360