]> andersk Git - splint.git/blobdiff - src/ctype.c
Fixed processing of multi-dimensional arrays.
[splint.git] / src / ctype.c
index 8253a71322221fd2a311ca5efe8751eebc3a622d..a03d657e219e67f3668498586c2759eb9717afe5 100644 (file)
@@ -354,29 +354,50 @@ ctype ctype_makeFixedArray (ctype c, size_t size)
   return res;
 }
 
+/*
+** In C, array terms appear backwards:
+**
+**        int a[5][7]
+**
+** declares an array of 5 elements, each of which is
+** an array of 7 int's.
+**
+** We represent this as,
+**
+**        array (array (int, 7), 5)
+**
+** Hence, the rightmost declaration is the innermost type.
+*/
+
 ctype ctype_makeInnerFixedArray (ctype c, size_t size)
 {
   ctype res;
 
+  DPRINTF (("makeinnerfixed: %s / %d", ctype_unparse (c), size));
+
   if (ctype_isFixedArray (c))
     {
       ctype cb = ctype_baseArrayPtr (c);
       size_t osize = ctype_getArraySize (c);
       
       res = ctype_makeFixedArray (ctype_makeInnerFixedArray (cb, size), osize);
+      DPRINTF (("res 1: %s", ctype_unparse (res)));
     }
   else if (ctype_isArray (c))
     {
       ctype cb = ctype_baseArrayPtr (c);
 
       res = ctype_makeArray (ctype_makeInnerFixedArray (cb, size));
+      DPRINTF (("res 2: %s", ctype_unparse (res)));
     }
   else
     {
       res = ctype_makeFixedArray (c, size);
+      DPRINTF (("res 3: %s", ctype_unparse (res)));
     }
 
-  DPRINTF (("Make inner fixed array: %s", ctype_unparse (res)));
+  DPRINTF (("Make inner fixed array: %s / base: %s", 
+           ctype_unparse (res), ctype_unparse (ctype_baseArrayPtr (res))));
   return res;
 }
 
@@ -393,6 +414,11 @@ ctype ctype_makeInnerArray (ctype c)
       
       res = ctype_makeFixedArray (ctype_makeInnerArray (cb), osize);
     }
+  else if (ctype_isArray (c)) 
+    {
+      ctype cb = ctype_baseArrayPtr (c);
+      res = ctype_makeArray (ctype_makeInnerArray (cb));
+    }
   else
     {
       res = ctype_makeArray (c);
@@ -1833,7 +1859,19 @@ ctype_isArray (ctype c)
 
 bool ctype_isIncompleteArray (ctype c)
 {
-  return (ctype_isArray (c) && !ctype_isFixedArray (c));
+  if (ctype_isArray (c)) 
+    {
+      if (ctype_isFixedArray (c)) 
+       {
+         return ctype_isIncompleteArray (ctype_baseArrayPtr (c));
+       }
+      else 
+       {
+         return TRUE;
+       }
+    }
+
+  return FALSE;
 }
 
 bool
This page took 0.047774 seconds and 4 git commands to generate.