[cfe-commits] r111602 - in /cfe/trunk: lib/Checker/RegionStore.cpp test/Analysis/array-struct-region.c

Jordy Rose jediknil at belkadan.com
Thu Aug 19 18:05:59 PDT 2010


Author: jrose
Date: Thu Aug 19 20:05:59 2010
New Revision: 111602

URL: http://llvm.org/viewvc/llvm-project?rev=111602&view=rev
Log:
Handle nested compound values in BindArray for multidimensional arrays. Fixes PR7945.

Modified:
    cfe/trunk/lib/Checker/RegionStore.cpp
    cfe/trunk/test/Analysis/array-struct-region.c

Modified: cfe/trunk/lib/Checker/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=111602&r1=111601&r2=111602&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/RegionStore.cpp (original)
+++ cfe/trunk/lib/Checker/RegionStore.cpp Thu Aug 19 20:05:59 2010
@@ -1504,6 +1504,8 @@
 
     if (ElementTy->isStructureOrClassType())
       store = BindStruct(store, ER, *VI);
+    else if (ElementTy->isArrayType())
+      store = BindArray(store, ER, *VI);
     else
       store = Bind(store, ValMgr.makeLoc(ER), *VI);
   }

Modified: cfe/trunk/test/Analysis/array-struct-region.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/array-struct-region.c?rev=111602&r1=111601&r2=111602&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/array-struct-region.c (original)
+++ cfe/trunk/test/Analysis/array-struct-region.c Thu Aug 19 20:05:59 2010
@@ -23,3 +23,25 @@
 
   return 42;
 }
+
+void nested_compound_literals(int rad) {
+  int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
+                   {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+  int a;
+
+  for (a = 0; a < 6; ++a) {
+      vec[a][0] *= rad; // no-warning
+      vec[a][1] *= rad; // no-warning
+  }
+}
+
+void nested_compound_literals_float(float rad) {
+  float vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
+                     {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+  int a;
+
+  for (a = 0; a < 6; ++a) {
+      vec[a][0] *= rad; // no-warning
+      vec[a][1] *= rad; // no-warning
+  }
+}





More information about the cfe-commits mailing list