diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
commit | b35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch) | |
tree | cdff4a5d1a715d4ad622fd8f190128b54bebe440 /test/Analysis/cxx-uninitialized-object.cpp | |
parent | 3748d41833787fcbf59cc5624e8d2b042a8991bc (diff) | |
parent | 741e05796da92b46d4f7bcbee00702ff37df6489 (diff) |
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103upstream/google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/cxx-uninitialized-object.cpp')
-rw-r--r-- | test/Analysis/cxx-uninitialized-object.cpp | 71 |
1 files changed, 63 insertions, 8 deletions
diff --git a/test/Analysis/cxx-uninitialized-object.cpp b/test/Analysis/cxx-uninitialized-object.cpp index 07006bea47..dde99dc954 100644 --- a/test/Analysis/cxx-uninitialized-object.cpp +++ b/test/Analysis/cxx-uninitialized-object.cpp @@ -1,11 +1,15 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \ -// RUN: -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \ -// RUN: -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \ -// RUN: -std=c++14 -verify %s - -// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \ -// RUN: -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \ -// RUN: -std=c++14 -verify %s +// RUN: %clang_analyze_cc1 -std=c++14 -verify %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=optin.cplusplus.UninitializedObject \ +// RUN: -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \ +// RUN: -analyzer-config \ +// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true + +// RUN: %clang_analyze_cc1 -std=c++14 -verify %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=optin.cplusplus.UninitializedObject \ +// RUN: -analyzer-config \ +// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true //===----------------------------------------------------------------------===// // Default constructor test. @@ -1130,3 +1134,54 @@ void fCXX11MemberInitTest2() { // TODO: we'd expect the warning: {{2 uninitializeds field}} CXX11MemberInitTest2(); // no-warning } + +//===----------------------------------------------------------------------===// +// "Esoteric" primitive type tests. +//===----------------------------------------------------------------------===// + +struct MyAtomicInt { + _Atomic(int) x; // expected-note{{uninitialized field 'this->x'}} + int dontGetFilteredByNonPedanticMode = 0; + + MyAtomicInt() {} // expected-warning{{1 uninitialized field}} +}; + +void _AtomicTest() { + MyAtomicInt b; +} + +struct VectorSizeLong { + VectorSizeLong() {} + __attribute__((__vector_size__(16))) long x; +}; + +void __vector_size__LongTest() { + // TODO: Warn for v.x. + VectorSizeLong v; + v.x[0] = 0; +} + +struct ComplexUninitTest { + ComplexUninitTest() {} + __complex__ float x; + __complex__ int y; +}; + +// FIXME: Currently this causes (unrelated to this checker) an assertion +// failure. +// +//struct ComplexInitTest { +// ComplexInitTest() { +// x = {1.0f, 1.0f}; +// y = {1, 1}; +// } +// __complex__ float x; +// __complex__ int y; +//}; + +void fComplexTest() { +// ComplexInitTest x; + + // TODO: we should emit a warning for x2.x and x2.y. + ComplexUninitTest x2; +} |