Skip to content

Commit 79789ab

Browse files
committed
Add note version
1 parent 2f18960 commit 79789ab

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ Improvements to Clang's diagnostics
327327

328328
- An error is now emitted when a ``musttail`` call is made to a function marked with the ``not_tail_called`` attribute. (#GH133509).
329329

330-
331330
Improvements to Clang's time-trace
332331
----------------------------------
333332

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3170,6 +3170,8 @@ def note_musttail_mismatch : Note<
31703170
"|has type mismatch at %ordinal3 parameter"
31713171
"%diff{ (expected $ but has $)|}1,2"
31723172
"|has different return type%diff{ ($ expected but has $)|}1,2}0">;
3173+
def note_musttail_disabled_by_not_tail_called : Note<
3174+
"'not_tail_called' attribute here prevents being called as a tail call">;
31733175
def err_musttail_callconv_mismatch : Error<
31743176
"cannot perform a tail call to function%select{| %1}0 because it uses an "
31753177
"incompatible calling convention">;

clang/lib/Sema/SemaStmt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr &MTA) {
719719

720720
if (const FunctionDecl *CalleeDecl = CE->getDirectCallee();
721721
CalleeDecl && CalleeDecl->hasAttr<NotTailCalledAttr>()) {
722-
Diag(St->getBeginLoc(), diag::err_musttail_mismatch) << true << CalleeDecl;
722+
Diag(St->getBeginLoc(), diag::err_musttail_mismatch) << /*show-function-callee=*/true << CalleeDecl;
723+
Diag(CalleeDecl->getLocation(), diag::note_musttail_disabled_by_not_tail_called) << CalleeDecl;
723724
return false;
724725
}
725726

clang/test/Sema/attr-musttail.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// RUN: %clang_cc1 -verify -fsyntax-only %s
22

3-
int __attribute__((not_tail_called)) foo1(int a) {
3+
int __attribute__((not_tail_called)) foo1(int a) {// expected-note {{'not_tail_called' attribute here prevents being called as a tail call}}
44
return a + 1;
55
}
66

77

88
int foo2(int a) {
99
[[clang::musttail]]
10-
return foo1(a); // expected-error {{cannot perform a tail call to function 'foo1' because its signature is incompatible with the calling function}}
10+
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'
1111
}
1212

1313
int main() {

0 commit comments

Comments
 (0)