llvm-project/clang/test/Sema/attr-musttail.cpp
MillePlateaux 061f87f75f
[Clang][Sema]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (#134465)
The error is emitted when a musttail call is made to a function marked
with the not_tail_called attribute.Closes #133509
2025-04-14 13:10:20 -07:00

18 lines
468 B
C++

// RUN: %clang_cc1 -verify -fsyntax-only %s
int __attribute__((not_tail_called)) foo1(int a) {// expected-note {{'not_tail_called' attribute 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}}
}
int main() {
int result = foo2(10);
return 0;
}