[clang] [Clang][Sema]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (PR #134465)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 14 10:27:36 PDT 2025


================
@@ -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) << CalleeDecl;
----------------
erichkeane wrote:

```suggestion
    Diag(CalleeDecl->getLocation(), diag::note_musttail_disabled_by_not_tail_called);
```

You don't need the `<< CalleeDecl` since that is how we fill in the `%0` type things in the diagnostic kinds message.  Since the added one doesn't have one, 

Aaron suggested instead of this diagnostic to reuse an existing one in a previous comment which I'm OK with (though I'm also ok with this one).  I'll let Aaron decide if he feels strongly enough to revert to the other one.

https://github.com/llvm/llvm-project/pull/134465


More information about the cfe-commits mailing list