Skip to content

Commit

Permalink
Only pop a cleanup scope in ~TaskFrameScope if one was pushed in Task…
Browse files Browse the repository at this point in the history
…FrameScope.
  • Loading branch information
VoxSciurorum authored and neboat committed Sep 1, 2024
1 parent 66a8741 commit 082303a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGCilk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ CodeGenFunction::TaskFrameScope::TaskFrameScope(CodeGenFunction &CGF)
CodeGenFunction::TaskFrameScope::~TaskFrameScope() {
if (LangOptions::Cilk_none == CGF.getLangOpts().getCilk())
return;
if (!CGF.CurSyncRegion)
if (!TaskFrame)
return;

// Pop the taskframe.
Expand Down
15 changes: 15 additions & 0 deletions clang/test/Cilk/266.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %clang_cc1 -triple x86_64-apple-macosx14.0.0 -emit-llvm -S -fopencilk -disable-llvm-passes -fcxx-exceptions -fexceptions -x c++ %s -o /dev/null
// expected-no-diagnostics
// Bug 266: unnecessary sync in catch block crashes compiler

extern int f();

// Nothing really to check here. If it compiles, great.
void try_catch() {
try {
f();
} catch (int x) {
_Cilk_sync;
}
}

0 comments on commit 082303a

Please sign in to comment.