[clang] [clang] Lifetime of locals must end before musttail call (PR #109255)
Oliver Stannard via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 20 02:19:38 PDT 2024
================
@@ -267,3 +267,30 @@ namespace ns {}
void TestCallNonValue() {
[[clang::musttail]] return ns; // expected-error {{unexpected namespace name 'ns': expected expression}}
}
+
+// Test diagnostics for lifetimes of local variables, which end earlier for a
+// musttail call than for a nowmal one.
+
+void TakesIntAndPtr(int, int *);
+void PassAddressOfLocal(int a, int *b) {
+ int c;
+ [[clang::musttail]] return TakesIntAndPtr(0, &c); // expected-warning {{address of stack memory associated with local variable 'c' passed to musttail function}}
----------------
ostannard wrote:
Done, and there was a different diagnostic message used for temporaries, so added a better wording for that.
https://github.com/llvm/llvm-project/pull/109255
More information about the cfe-commits
mailing list