Files
llvm-project/clang/test/CodeGenCXX/musttail-noexcept-error.cpp
Paweł Bylica b744548871 [Clang] Allow musttail in noexcept functions when callee is nounwind (#190945)
noexcept functions push an EHTerminateScope onto the cleanup stack. The
musttail codegen did not know how to skip this scope, causing a "cannot
compile this tail call skipping over cleanups yet" error even when both
caller and callee are noexcept.

Skip the EHTerminateScope when the callee is nounwind (noexcept). The
callee's own noexcept handler prevents any exception from propagating,
so the caller's terminate handler is unnecessary.

Fixes #53087.
2026-04-08 23:06:49 +02:00

10 lines
388 B
C++

// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -emit-llvm %s -triple x86_64-unknown-linux-gnu -o /dev/null -verify
// Negative: musttail to a non-noexcept callee from a noexcept function.
int ThrowingFunc(int);
int TestThrowingCallee(int x) noexcept {
[[clang::musttail]] return ThrowingFunc(x); // expected-error {{'musttail' in a noexcept function requires a noexcept callee}}
}