-
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 8 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,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; | ||||||
|
||||||
| Diag(CalleeDecl->getLocation(), diag::note_musttail_disabled_by_not_tail_called) << CalleeDecl; | |
| 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.
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.
I don't feel strongly about reusing the existing diagnostic, this new note is fine by me.
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) {// expected-note {{'not_tail_called' attribute here prevents being called as a tail call}} | ||||||
| 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}} `note: 'not_tail_called' attribute here prevents being called as a tail call' | ||||||
|
||||||
| return foo1(a); // expected-error {{cannot perform a tail call to function 'foo1' because its signature is incompatible with the calling function}} `note: 'not_tail_called' attribute here prevents being called as a tail call' | |
| return foo1(a); // expected-error {{cannot perform a tail call to function 'foo1' because its signature is incompatible with the calling function}} |
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.