diff options
author | MillePlateaux <liulambda@outlook.com> | 2025-04-15 04:10:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-14 13:10:20 -0700 |
commit | 061f87f75f38e80e7494b5f7235103f7f11a36c3 (patch) | |
tree | 8879376f59b1f86d3e04f961e71ff7292f2fd70c /clang/lib/Sema/SemaStmt.cpp | |
parent | be4c99ae112f572695c3e187f4ef4ac4cd592783 (diff) | |
download | llvm-061f87f75f38e80e7494b5f7235103f7f11a36c3.zip llvm-061f87f75f38e80e7494b5f7235103f7f11a36c3.tar.gz llvm-061f87f75f38e80e7494b5f7235103f7f11a36c3.tar.bz2 |
[Clang][Sema]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (#134465)
The error is emitted when a musttail call is made to a function marked
with the not_tail_called attribute.Closes #133509
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index e1b9ccc..39c2e15 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -717,6 +717,13 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr &MTA) { return false; } + if (const FunctionDecl *CalleeDecl = CE->getDirectCallee(); + CalleeDecl && CalleeDecl->hasAttr<NotTailCalledAttr>()) { + Diag(St->getBeginLoc(), diag::err_musttail_mismatch) << /*show-function-callee=*/true << CalleeDecl; + Diag(CalleeDecl->getLocation(), diag::note_musttail_disabled_by_not_tail_called); + return false; + } + if (const auto *EWC = dyn_cast<ExprWithCleanups>(E)) { if (EWC->cleanupsHaveSideEffects()) { Diag(St->getBeginLoc(), diag::err_musttail_needs_trivial_args) << &MTA; |