diff options
Diffstat (limited to 'compiler-rt/test/asan/TestCases/Windows/basic_exception_handling.cpp')
| -rw-r--r-- | compiler-rt/test/asan/TestCases/Windows/basic_exception_handling.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/compiler-rt/test/asan/TestCases/Windows/basic_exception_handling.cpp b/compiler-rt/test/asan/TestCases/Windows/basic_exception_handling.cpp new file mode 100644 index 000000000000..8d1b9ef17393 --- /dev/null +++ b/compiler-rt/test/asan/TestCases/Windows/basic_exception_handling.cpp @@ -0,0 +1,34 @@ +// RUN: %clangxx_asan %s -o %t +// RUN: %run %t | FileCheck %s + +// This test tests that declaring a parameter in a catch-block does not produce a false positive +// ASan error on Windows. + +// This code is based on the repro in https://github.com/google/sanitizers/issues/749 +#include <cstdio> +#include <exception> +#include <stdexcept> + +void throwInFunction() { throw std::runtime_error("test2"); } + +int main() { + // case 1: direct throw + try { + throw std::runtime_error("test1"); + } catch (const std::exception &ex) { + puts(ex.what()); + // CHECK: test1 + } + + // case 2: throw in function + try { + throwInFunction(); + } catch (const std::exception &ex) { + puts(ex.what()); + // CHECK: test2 + } + + printf("Success!\n"); + // CHECK: Success! + return 0; +} |
