diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp index d6feabea534b..e0e1c3617dee 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -535,7 +535,7 @@ void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL, const Expr *Init = CL->getInitializer(); SVal V = State->getSVal(CL->getInitializer(), LCtx); - if (isa(Init)) { + if (isa(Init) || isa(Init)) { // No work needed. Just pass the value up to this expression. } else { assert(isa(Init)); diff --git a/clang/test/Analysis/initializer.cpp b/clang/test/Analysis/initializer.cpp index e9658a067c2f..6359b93d0a29 100644 --- a/clang/test/Analysis/initializer.cpp +++ b/clang/test/Analysis/initializer.cpp @@ -211,7 +211,7 @@ namespace CXX_initializer_lists { struct C { C(std::initializer_list list); }; -void foo() { +void testPointerEscapeIntoLists() { C empty{}; // no-crash // Do not warn that 'x' leaks. It might have been deleted by @@ -219,4 +219,8 @@ void foo() { int *x = new int; C c{x}; // no-warning } + +void testPassListsWithExplicitConstructors() { + (void)(std::initializer_list){12}; // no-crash +} }