]> granicus.if.org Git - clang/commitdiff
Handle nested compound values in BindArray for multidimensional arrays. Fixes PR7945.
authorJordy Rose <jediknil@belkadan.com>
Fri, 20 Aug 2010 01:05:59 +0000 (01:05 +0000)
committerJordy Rose <jediknil@belkadan.com>
Fri, 20 Aug 2010 01:05:59 +0000 (01:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111602 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Checker/RegionStore.cpp
test/Analysis/array-struct-region.c

index d6422ab338f9b028965c504cf48e52c8c4475341..ab3234774ff1a76110b3ada620f1a6b2bc11f360 100644 (file)
@@ -1504,6 +1504,8 @@ Store RegionStoreManager::BindArray(Store store, const TypedRegion* R,
 
     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);
   }
index 2966d13004e0979885557b2093e1490695fe0085..dabd25bb1f50737534bf9c3250ee9078762d76c8 100644 (file)
@@ -23,3 +23,25 @@ int string_literal_init() {
 
   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
+  }
+}