From: Jordan Rose Date: Sat, 16 Jun 2012 01:28:03 +0000 (+0000) Subject: [analyzer] Array CompoundLiteralExprs need to be treated like lvalues. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3083d3c550dedf68101dd9133905c3c7d35662bd;p=clang [analyzer] Array CompoundLiteralExprs need to be treated like lvalues. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158588 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 6707860009..0056089af9 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -408,7 +408,7 @@ void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL, const LocationContext *LC = Pred->getLocationContext(); state = state->bindCompoundLiteral(CL, LC, ILV); - if (CL->isGLValue()) + if (CL->isGLValue() || CL->getType()->isArrayType()) B.generateNode(CL, Pred, state->BindExpr(CL, LC, state->getLValue(CL, LC))); else B.generateNode(CL, Pred, state->BindExpr(CL, LC, ILV)); diff --git a/test/Analysis/cxx-crashes.cpp b/test/Analysis/cxx-crashes.cpp index 1ee81a2023..8912bf68de 100644 --- a/test/Analysis/cxx-crashes.cpp +++ b/test/Analysis/cxx-crashes.cpp @@ -70,3 +70,8 @@ void vla(int n) { clang_analyzer_eval(structs[0].x == 1); // expected-warning{{TRUE}} } +void useIntArray(int []); +void testIntArrayLiteral() { + useIntArray((int []){ 1, 2, 3 }); +} +