]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / asan / TestCases / alloca_instruments_all_paddings.cc
1 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-allocas %s -o %t
2 // RUN: %clangxx_asan -O3 -mllvm -asan-instrument-allocas %s -o %t
3 // RUN: %run %t 2>&1
4 //
5
6 #include "sanitizer/asan_interface.h"
7 #include <assert.h>
8
9 __attribute__((noinline)) void foo(int index, int len) {
10 volatile char str[len] __attribute__((aligned(32)));
11 assert(!(reinterpret_cast<long>(str) & 31L));
12 char *q = (char *)__asan_region_is_poisoned((char *)str, 64);
13 assert(q && ((q - str) == index));
14 }
15
16 int main(int argc, char **argv) {
17 for (int i = 1; i < 33; ++i)
18 foo(i, i);
19
20 for (int i = 1; i < 33; ++i)
21 foo(i, i);
22
23 return 0;
24 }