https://github.com/GkvJwa updated https://github.com/llvm/llvm-project/pull/172287
>From b9e4660051b70d266a6542586959aa4caf863c38 Mon Sep 17 00:00:00 2001 From: GkvJwa <[email protected]> Date: Wed, 24 Dec 2025 23:32:24 +0800 Subject: [PATCH] Test --- clang/lib/CodeGen/CGCleanup.cpp | 6 +++++- clang/test/CodeGenCXX/exceptions-seh.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp index 28ac9bf396356..2afd16e8d5708 100644 --- a/clang/lib/CodeGen/CGCleanup.cpp +++ b/clang/lib/CodeGen/CGCleanup.cpp @@ -191,8 +191,12 @@ void *EHScopeStack::pushCleanup(CleanupKind Kind, size_t Size) { // consistent with MSVC's behavior, except in the presence of -EHa. // Check getInvokeDest() to generate llvm.seh.scope.begin() as needed. if (CGF->getLangOpts().EHAsynch && IsEHCleanup && !IsLifetimeMarker && - CGF->getTarget().getCXXABI().isMicrosoft() && CGF->getInvokeDest()) + CGF->getTarget().getCXXABI().isMicrosoft() && CGF->getInvokeDest()) { + if (IsNormalCleanup && !CGF->SEHCodeSlotStack.empty()) + CGF->CGM.getDiags().Report(CGF->CurFuncDecl->getLocation(), + diag::err_seh_expected_handler); CGF->EmitSehCppScopeBegin(); + } return Scope->getCleanupBuffer(); } diff --git a/clang/test/CodeGenCXX/exceptions-seh.cpp b/clang/test/CodeGenCXX/exceptions-seh.cpp index bb374dd1f5bd5..2f5c43b7cbd58 100644 --- a/clang/test/CodeGenCXX/exceptions-seh.cpp +++ b/clang/test/CodeGenCXX/exceptions-seh.cpp @@ -4,6 +4,10 @@ // RUN: %clang_cc1 -std=c++11 -fblocks -fms-extensions %s -triple=x86_64-windows-msvc -emit-llvm \ // RUN: -o - -mconstructor-aliases -O1 -disable-llvm-passes | \ // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=NOCXX +// RUN: %clang_cc1 -triple x86_64-windows -fasync-exceptions -fcxx-exceptions -fexceptions \ +// RUN: -fms-extensions -x c++ -emit-llvm -verify %s -DERR1 +// RUN: %clang_cc1 -triple x86_64-windows -fasync-exceptions -fcxx-exceptions -fexceptions \ +// RUN: -fms-extensions -x c++ -emit-llvm -verify %s -DERR2 extern "C" unsigned long _exception_code(); extern "C" void might_throw(); @@ -175,3 +179,19 @@ void use_inline() { // CHECK: attributes #[[NOINLINE]] = { {{.*noinline.*}} } void seh_in_noexcept() noexcept { __try {} __finally {} } + +#if defined(ERR1) +void seh_unwinding() { // expected-error{{expected '__except' or '__finally' block}} + __try { + HasCleanup x; + } __except (1) { + } +} +#elif defined(ERR2) +void seh_unwinding() { // expected-error{{expected '__except' or '__finally' block}} + __try { + } __except (1) { + HasCleanup x; + } +} +#endif _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
