]> granicus.if.org Git - clang/commitdiff
[analyzer] Array CompoundLiteralExprs need to be treated like lvalues.
authorJordan Rose <jordan_rose@apple.com>
Sat, 16 Jun 2012 01:28:03 +0000 (01:28 +0000)
committerJordan Rose <jordan_rose@apple.com>
Sat, 16 Jun 2012 01:28:03 +0000 (01:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158588 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/ExprEngineC.cpp
test/Analysis/cxx-crashes.cpp

index 6707860009352ba8224ceaf44b5ad60da42b2e75..0056089af9aaf19c1abd8e0890ebf28ba4f95a89 100644 (file)
@@ -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));
index 1ee81a20235e6fe74bbfb046316124bd43d7da4a..8912bf68de3fff49da4cb034ade151a0c4392feb 100644 (file)
@@ -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 });
+}
+