1 // This is the ASAN test of the same name ported to HWAsan.
3 // RUN: %clangxx_hwasan -std=c++11 -O0 %s -o %t
4 // RUN: %clangxx_hwasan -fno-exceptions -std=c++11 -O0 %s -o %t-noexcept
6 // RUN: not %run %t 0 2>&1 | FileCheck %s
7 // RUN: not %run %t 1 2>&1 | FileCheck %s
8 // RUN: not %run %t 2 2>&1 | FileCheck %s
9 // RUN: not %run %t 3 2>&1 | FileCheck %s
10 // RUN: not %run %t 4 2>&1 | FileCheck %s
11 // RUN: not %run %t 5 2>&1 | FileCheck %s
12 // RUN: not %run %t 6 2>&1 | FileCheck %s
13 // RUN: not %run %t 7 2>&1 | FileCheck %s
14 // RUN: not %run %t 8 2>&1 | FileCheck %s
15 // RUN: not %run %t 9 2>&1 | FileCheck %s
16 // RUN: not %run %t 10 2>&1 | FileCheck %s
18 // RUN: not %run %t-noexcept 0 2>&1 | FileCheck %s
19 // RUN: not %run %t-noexcept 1 2>&1 | FileCheck %s
20 // RUN: not %run %t-noexcept 2 2>&1 | FileCheck %s
21 // RUN: not %run %t-noexcept 3 2>&1 | FileCheck %s
22 // RUN: not %run %t-noexcept 4 2>&1 | FileCheck %s
23 // RUN: not %run %t-noexcept 5 2>&1 | FileCheck %s
24 // RUN: not %run %t-noexcept 6 2>&1 | FileCheck %s
25 // RUN: not %run %t-noexcept 7 2>&1 | FileCheck %s
26 // RUN: not %run %t-noexcept 8 2>&1 | FileCheck %s
27 // RUN: not %run %t-noexcept 9 2>&1 | FileCheck %s
28 // RUN: not %run %t-noexcept 10 2>&1 | FileCheck %s
30 // REQUIRES: aarch64-target-arch || riscv64-target-arch
38 void Store(T
*ptr
) { t
= ptr
; }
40 void Access() { *t
= {}; }
45 template <class T
, size_t N
>
48 void Store(Type
*ptr
) { t
= *ptr
; }
50 void Access() { *t
= {}; }
56 __attribute__((noinline
)) void test() {
64 // CHECK: ERROR: HWAddressSanitizer: tag-mismatch
65 // CHECK: #{{[0-9]+}} 0x{{.*}} in {{(void )?test.*\((void)?\) .*}}use-after-scope-types.cpp
66 // CHECK: Cause: stack tag-mismatch
69 int main(int argc
, char **argv
) {
70 using Tests
= void (*)();
78 &test
<std::vector
<std::string
>>,
85 int n
= atoi(argv
[1]);
86 if (n
== sizeof(tests
) / sizeof(tests
[0])) {