llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) <details> <summary>Changes</summary> If the next token after 'cancel' is a special token, we would trigger an assertion. We should be consuming any token, same as elsewhere in the function. Note, we could check for an unknown directive and do different error recovery, but that caused too many behavioral changes for other tests in the form of "unexpected tokens ignored" diagnostics that didn't seem like an improvement for the test cases. Fixes #<!-- -->139360 --- Full diff: https://github.com/llvm/llvm-project/pull/139577.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Parse/ParseOpenMP.cpp (+1-1) - (modified) clang/test/OpenMP/cancel_messages.cpp (+5) ``````````diff 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 `````````` </details> https://github.com/llvm/llvm-project/pull/139577 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits