[clang] [llvm] [Clang] Add `__builtin_stack_address` (PR #148281)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 5 10:06:02 PDT 2025
================
@@ -36,3 +36,8 @@ void* h(unsigned x) {
// expected-error at +1 {{argument value 1048575 is outside the valid range [0, 65535]}}
return __builtin_frame_address(0xFFFFF);
}
+
+void *i() {
+// expected-error at +1 {{too many arguments to function call, expected 0, have 1}}
+return __builtin_stack_address(0);
----------------
moorabbit wrote:
> // As a global variable where there is no stack address to get.
// This should be diagnosed as an error?
void *ptr = __builtin_stack_address();
It looks like GCC doesn't diagnose this as an error (https://godbolt.org/z/x35e114de) and returns the stack address of the initialization function. I'm not sure if it's intended or not.
Should we still diagnose this as an error?
> Should we also have tests for what happens with naked functions or other kind of odd situations where the stack may be different from the normal case?
Noted, will add them, thanks!
https://github.com/llvm/llvm-project/pull/148281
More information about the llvm-commits
mailing list