-
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 7 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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) << true << CalleeDecl; | ||||||
|
||||||
| Diag(St->getBeginLoc(), diag::err_musttail_mismatch) << true << CalleeDecl; | |
| Diag(St->getBeginLoc(), diag::err_musttail_mismatch) << /*show-function-callee=*/true << CalleeDecl; |
Not exactly our policy, but makes it way easier to understand what is going on here.
AaronBallman marked this conversation as resolved.
Show resolved
Hide resolved
| 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 'foo1' 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.