diff options
Diffstat (limited to 'test/Analysis/cxx-crashes.cpp')
-rw-r--r-- | test/Analysis/cxx-crashes.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/test/Analysis/cxx-crashes.cpp b/test/Analysis/cxx-crashes.cpp index 17fc74d..8912bf6 100644 --- a/test/Analysis/cxx-crashes.cpp +++ b/test/Analysis/cxx-crashes.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s + +void clang_analyzer_eval(bool); int f1(char *dst) { char *p = dst + 4; @@ -54,3 +56,22 @@ struct C { void C::f() { } } + + +void vla(int n) { + int nums[n]; + nums[0] = 1; + clang_analyzer_eval(nums[0] == 1); // expected-warning{{TRUE}} + + // This used to fail with MallocChecker on, and /only/ in C++ mode. + // This struct is POD, though, so it should be fine to put it in a VLA. + struct { int x; } structs[n]; + structs[0].x = 1; + clang_analyzer_eval(structs[0].x == 1); // expected-warning{{TRUE}} +} + +void useIntArray(int []); +void testIntArrayLiteral() { + useIntArray((int []){ 1, 2, 3 }); +} + |