[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / use-after-scope-goto.cpp
blob8b23f60d8b5b84e7f44decb63f53a2b0ab11eb7a
1 // This is the ASAN test of the same name ported to HWAsan.
3 // RUN: %clangxx_hwasan -O0 %s -o %t && %run %t
5 // Function jumps over variable initialization making lifetime analysis
6 // ambiguous. Asan should ignore such variable and program must not fail.
8 // REQUIRES: aarch64-target-arch || riscv64-target-arch
10 #include <stdlib.h>
12 int *ptr;
14 void f1(int cond) {
15 if (cond)
16 goto label;
17 int tmp;
19 label:
20 ptr = &tmp;
21 *ptr = 5;
24 void f2(int cond) {
25 switch (cond) {
26 case 1: {
27 ++cond;
28 int tmp;
29 ptr = &tmp;
30 exit(0);
31 case 2:
32 ptr = &tmp;
33 *ptr = 5;
34 exit(0);
39 void f3(int cond) {
41 int tmp;
42 goto l2;
43 l1:
44 ptr = &tmp;
45 *ptr = 5;
47 exit(0);
49 l2:
50 goto l1;
53 void use(int *x) {
54 static int c = 10;
55 if (--c == 0)
56 exit(0);
57 (*x)++;
60 void f4() {
62 int x;
63 l2:
64 use(&x);
65 goto l1;
67 l1:
68 goto l2;
71 int main() {
72 f1(1);
73 f2(1);
74 f3(1);
75 f4();
76 return 0;