[clang] [llvm] [Clang] Add `__builtin_stack_address` (PR #148281)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 20 09:04:11 PDT 2025
================
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify %s -triple x86_64-unknown-unknown -DTEST_x64
+// RUN: %clang_cc1 -verify %s -triple i386-unknown-unknown -DTEST_x86
+// RUN: %clang_cc1 -verify %s -triple riscv32-unknown-unknown -DTEST_riscv32
+// RUN: %clang_cc1 -verify %s -triple riscv64-unknown-unknown -DTEST_riscv64
+// RUN: %clang_cc1 -verify %s -triple aarch64-unknown-unknown -DTEST_aarch64
+
+#if defined(TEST_x64) || defined(TEST_x86)
+// expected-no-diagnostics
+void *a() {
+return __builtin_stack_address();
+}
+#else
+void *a() {
+return __builtin_stack_address(); // expected-error {{builtin is not supported on this target}}
+}
+#endif
----------------
Sirraide wrote:
```suggestion
// expected-no-diagnostics
void *a() {
return __builtin_stack_address(); // x86-error {{builtin is not supported on this target}}
}
```
Instead of duplicating everything like that, you can just do this and write e.g. `-verify=x86` in the RUN lines for `x86`/`x64` (`-verify` is short for `-verify=expected`).
https://github.com/llvm/llvm-project/pull/148281
More information about the cfe-commits
mailing list