diff options
Diffstat (limited to 'test/Analysis/initializer.cpp')
-rw-r--r-- | test/Analysis/initializer.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/test/Analysis/initializer.cpp b/test/Analysis/initializer.cpp index c73635686d83f..6359b93d0a299 100644 --- a/test/Analysis/initializer.cpp +++ b/test/Analysis/initializer.cpp @@ -1,7 +1,9 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s void clang_analyzer_eval(bool); +#include "Inputs/system-header-simulator-cxx.h" + class A { int x; public: @@ -204,3 +206,21 @@ struct C { const char(&f)[2]; }; } + +namespace CXX_initializer_lists { +struct C { + C(std::initializer_list<int *> list); +}; +void testPointerEscapeIntoLists() { + C empty{}; // no-crash + + // Do not warn that 'x' leaks. It might have been deleted by + // the destructor of 'c'. + int *x = new int; + C c{x}; // no-warning +} + +void testPassListsWithExplicitConstructors() { + (void)(std::initializer_list<int>){12}; // no-crash +} +} |