From b638c48819d772ec36bbc8036da2cbb4044126ec Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Thu, 8 Sep 2016 06:43:02 +0000 Subject: [PATCH] [asan] Test that asan does not report use-after-scope if program jumped over variable declaration. Summary: Test to check if PR28267 workaround works. PR28267 PR27453 Reviewers: eugenis Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D24323 llvm-svn: 280908 --- .../asan/TestCases/use-after-scope-goto.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 compiler-rt/test/asan/TestCases/use-after-scope-goto.c diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-goto.c b/compiler-rt/test/asan/TestCases/use-after-scope-goto.c new file mode 100644 index 000000000000..e69cc7180653 --- /dev/null +++ b/compiler-rt/test/asan/TestCases/use-after-scope-goto.c @@ -0,0 +1,21 @@ +// RUN: %clang_asan -O0 -fsanitize-address-use-after-scope %s -o %t && %run %t + +// Function jumps over variable initialization making lifetime analysis +// ambiguous. Asan should ignore such variable and program must not fail. + +int *ptr; + +void f(int cond) { + if (cond) + goto label; + int tmp = 1; + +label: + ptr = &tmp; + *ptr = 5; +} + +int main() { + f(1); + return 0; +}