xref: /llvm-project/compiler-rt/test/asan/TestCases/inline.cpp (revision 5fe1e55d35413b1904cfcf16ec15495398921fe5)
1 // RUN: %clangxx_asan -O3 %s -o %t && %run %t
2 
3 // Test that no_sanitize_address attribute applies even when the function would
4 // be normally inlined.
5 
6 #include <stdlib.h>
7 
8 __attribute__((no_sanitize_address))
f(int * p)9 int f(int *p) {
10   return *p; // BOOOM?? Nope!
11 }
12 
main(int argc,char ** argv)13 int main(int argc, char **argv) {
14   int * volatile x = (int*)malloc(2*sizeof(int) + 2);
15   int res = f(x + 2);
16   free(x);
17   if (res)
18     exit(0);
19   return 0;
20 }
21