Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / use-after-scope-goto.cpp
blobb0acd26fe932d688bde52c2ea7de68a55ae2669b
1 // RUN: %clangxx_asan -O0 %s -o %t && %run %t
3 // Function jumps over variable initialization making lifetime analysis
4 // ambiguous. Asan should ignore such variable and program must not fail.
6 #include <stdlib.h>
8 int *ptr;
10 void f1(int cond) {
11 if (cond)
12 goto label;
13 int tmp;
15 label:
16 ptr = &tmp;
17 *ptr = 5;
20 void f2(int cond) {
21 switch (cond) {
22 case 1: {
23 ++cond;
24 int tmp;
25 ptr = &tmp;
26 exit(0);
27 case 2:
28 ptr = &tmp;
29 *ptr = 5;
30 exit(0);
35 void f3(int cond) {
37 int tmp;
38 goto l2;
39 l1:
40 ptr = &tmp;
41 *ptr = 5;
43 exit(0);
45 l2:
46 goto l1;
49 void use(int *x) {
50 static int c = 10;
51 if (--c == 0)
52 exit(0);
53 (*x)++;
56 void f4() {
58 int x;
59 l2:
60 use(&x);
61 goto l1;
63 l1:
64 goto l2;
67 int main() {
68 f1(1);
69 f2(1);
70 f3(1);
71 f4();
72 return 0;