OSDN Git Service

2008-07-29 Aaron W. LaFramboise <aaronavay62@aaronwl.com>
[pf3gnuchains/gcc-fork.git] / libgfortran / generated / matmul_c8.c
index 5f4bdec..9d66949 100644 (file)
@@ -135,6 +135,47 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
        = internal_malloc_size (sizeof (GFC_COMPLEX_8) * size0 ((array_t *) retarray));
       retarray->offset = 0;
     }
+    else if (compile_options.bounds_check)
+      {
+       index_type ret_extent, arg_extent;
+
+       if (GFC_DESCRIPTOR_RANK (a) == 1)
+         {
+           arg_extent = b->dim[1].ubound + 1 - b->dim[1].lbound;
+           ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+           if (arg_extent != ret_extent)
+             runtime_error ("Incorrect extent in return array in"
+                            " MATMUL intrinsic: is %ld, should be %ld",
+                            (long int) ret_extent, (long int) arg_extent);
+         }
+       else if (GFC_DESCRIPTOR_RANK (b) == 1)
+         {
+           arg_extent = a->dim[0].ubound + 1 - a->dim[0].lbound;
+           ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+           if (arg_extent != ret_extent)
+             runtime_error ("Incorrect extent in return array in"
+                            " MATMUL intrinsic: is %ld, should be %ld",
+                            (long int) ret_extent, (long int) arg_extent);         
+         }
+       else
+         {
+           arg_extent = a->dim[0].ubound + 1 - a->dim[0].lbound;
+           ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+           if (arg_extent != ret_extent)
+             runtime_error ("Incorrect extent in return array in"
+                            " MATMUL intrinsic for dimension 1:"
+                            " is %ld, should be %ld",
+                            (long int) ret_extent, (long int) arg_extent);
+
+           arg_extent = b->dim[1].ubound + 1 - b->dim[1].lbound;
+           ret_extent = retarray->dim[1].ubound + 1 - retarray->dim[1].lbound;
+           if (arg_extent != ret_extent)
+             runtime_error ("Incorrect extent in return array in"
+                            " MATMUL intrinsic for dimension 2:"
+                            " is %ld, should be %ld",
+                            (long int) ret_extent, (long int) arg_extent);
+         }
+      }
 
 
   if (GFC_DESCRIPTOR_RANK (retarray) == 1)
@@ -170,7 +211,10 @@ matmul_c8 (gfc_array_c8 * const restrict retarray,
     }
 
   if (count != b->dim[0].ubound + 1 - b->dim[0].lbound)
-    runtime_error ("dimension of array B incorrect in MATMUL intrinsic");
+    {
+      if (count > 0 || b->dim[0].ubound + 1 - b->dim[0].lbound > 0)
+       runtime_error ("dimension of array B incorrect in MATMUL intrinsic");
+    }
 
   if (GFC_DESCRIPTOR_RANK (b) == 1)
     {