diff options
-rw-r--r-- | lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 | ||||
-rw-r--r-- | test/Analysis/initializer.cpp | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index a1fc29eb7e..26a3f9b1f5 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -404,7 +404,7 @@ void ExprEngine::ProcessInitializer(const CFGInitializer Init, if (BMI->isAnyMemberInitializer()) { // Constructors build the object directly in the field, // but non-objects must be copied in from the initializer. - const Expr *Init = BMI->getInit(); + const Expr *Init = BMI->getInit()->IgnoreImplicit(); if (!isa<CXXConstructExpr>(Init)) { SVal FieldLoc; if (BMI->isIndirectMemberInitializer()) diff --git a/test/Analysis/initializer.cpp b/test/Analysis/initializer.cpp index d4f336977e..ab2eb90143 100644 --- a/test/Analysis/initializer.cpp +++ b/test/Analysis/initializer.cpp @@ -80,3 +80,33 @@ class StringWrapper { public: StringWrapper(const char *input) : str(strdup(input)) {} // no-warning }; + + +// PR15070 - Constructing a type containing a non-POD array mistakenly +// tried to perform a bind instead of relying on the CXXConstructExpr, +// which caused a cast<> failure in RegionStore. +namespace DefaultConstructorWithCleanups { + class Element { + public: + int value; + + class Helper { + public: + ~Helper(); + }; + Element(Helper h = Helper()); + }; + class Wrapper { + public: + Element arr[2]; + + Wrapper(); + }; + + Wrapper::Wrapper() /* initializers synthesized */ {} + + int test() { + Wrapper w; + return w.arr[0].value; // no-warning + } +} |