diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Analysis/new.cpp | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp index 3f16c624922..1342e4149f6 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp @@ -431,8 +431,6 @@ void ExprEngine::VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred, if (!isa<CXXConstructExpr>(Init)) { assert(Bldr.getResults().size() == 1); Bldr.takeNodes(NewN); - - assert(!CNE->getType()->getPointeeCXXRecordDecl()); evalBind(Dst, CNE, NewN, Result, State->getSVal(Init, LCtx), /*FirstInit=*/IsStandardGlobalOpNewFunction); } diff --git a/clang/test/Analysis/new.cpp b/clang/test/Analysis/new.cpp index 8d3eee9baa6..27cbb0816b2 100644 --- a/clang/test/Analysis/new.cpp +++ b/clang/test/Analysis/new.cpp @@ -170,6 +170,16 @@ void testUsingThisAfterDelete() { c->f(0); // no-warning } +void testAggregateNew() { + struct Point { int x, y; }; + new Point{1, 2}; // no crash + + Point p; + new (&p) Point{1, 2}; // no crash + clang_analyzer_eval(p.x == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(p.y == 2); // expected-warning{{TRUE}} +} + //-------------------------------- // Incorrectly-modelled behavior //-------------------------------- |

