diff options
author | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
commit | 554bcb69c2d785a011a30e7db87a36a87fe7db10 (patch) | |
tree | 9abb1a658a297776086f4e0dfa6ca533de02104e /test/Analysis/cxx-crashes.cpp | |
parent | bb67ca86b31f67faee50bd10c3b036d65751745a (diff) | |
download | FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.zip FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.tar.gz |
Vendor import of clang trunk r161861:
http://llvm.org/svn/llvm-project/cfe/trunk@161861
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 }); +} + |