-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang][Sema]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error #134465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
596679a
8999e0f
bf4921f
28acee4
2b285ec
abedbaf
2f18960
79789ab
670da2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3161,7 +3161,7 @@ def err_musttail_member_mismatch : Error< | |
| def note_musttail_callee_defined_here : Note<"%0 declared here">; | ||
| def note_tail_call_required : Note<"tail call required by %0 attribute here">; | ||
| def err_musttail_mismatch : Error< | ||
| "cannot perform a tail call to function%select{| %1}0 because its signature " | ||
| "cannot perform a tail call to function %select{| %1}0 because its signature " | ||
|
||
| "is incompatible with the calling function">; | ||
| def note_musttail_mismatch : Note< | ||
| "target function " | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -717,6 +717,12 @@ 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) << &MTA; | ||
|
||
| return false; | ||
AaronBallman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| if (const auto *EWC = dyn_cast<ExprWithCleanups>(E)) { | ||
| if (EWC->cleanupsHaveSideEffects()) { | ||
| Diag(St->getBeginLoc(), diag::err_musttail_needs_trivial_args) << &MTA; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // RUN: %clang_cc1 -verify -fsyntax-only %s | ||
|
|
||
| int __attribute__((not_tail_called)) foo1(int a) { | ||
| return a + 1; | ||
| } | ||
|
|
||
|
|
||
| int foo2(int a) { | ||
| [[clang::musttail]] | ||
| return foo1(a); // expected-error{{cannot perform a tail call to function 'musttail' because its signature is incompatible with the calling function}} | ||
| } | ||
|
|
||
| int main() { | ||
| int result = foo2(10); | ||
| return 0; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should only be a single -new-line at the end of this list.