[clang] [llvm][Stmt]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (PR #134465)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 4 17:18:21 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (MillePlateaux)
<details>
<summary>Changes</summary>
Added judgment statements and accurately reported errors.Closes #<!-- -->133509
---
Full diff: https://github.com/llvm/llvm-project/pull/134465.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaStmt.cpp (+8)
``````````diff
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index e1b9ccc693bd5..c8354198a5614 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -717,6 +717,14 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr &MTA) {
return false;
}
+ if (const FunctionDecl *CalleeDecl = CE->getDirectCallee()) {
+ if (CalleeDecl->hasAttr<NotTailCalledAttr>()) {
+ Diag(St->getBeginLoc(), diag::err_musttail_conflicts_with_not_tail_called)
+ << &MTA;
+ return false;
+ }
+ }
+
if (const auto *EWC = dyn_cast<ExprWithCleanups>(E)) {
if (EWC->cleanupsHaveSideEffects()) {
Diag(St->getBeginLoc(), diag::err_musttail_needs_trivial_args) << &MTA;
``````````
</details>
https://github.com/llvm/llvm-project/pull/134465
More information about the cfe-commits
mailing list