[clang] [clang][Sema] Add noinline check for __builtin_frame_address and __builtin_return_address (PR #82966)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 4 12:15:58 PST 2024
================
@@ -28,4 +36,28 @@ void *foo()
{
return RA<2>(); // expected-note{{in instantiation of function template specialization 'RA<2>' requested here}}
}
-#endif
+
+void* f() {
+ return ([&] () {
+ return __builtin_frame_address(0); // expected-warning{{calling '__builtin_frame_address' in function not marked __attribute__((noinline)) may return a caller's frame address}}
+ })();
+}
+
+void* g() {
+ return ([&] () __attribute__((noinline)) {
+ return __builtin_frame_address(0);
+ })();
+}
+
+void* h() {
+ return ([&] () {
+ return __builtin_return_address(0); // expected-warning{{calling '__builtin_return_address' in function not marked __attribute__((noinline)) may return a caller's return address}}
+ })();
+}
+
+void* i() {
+ return ([&] () __attribute__((noinline)) {
+ return __builtin_return_address(0);
+ })();
+}
+#endif
----------------
AaronBallman wrote:
Please add the newline back to the end of the file.
https://github.com/llvm/llvm-project/pull/82966
More information about the cfe-commits
mailing list