Commits

Iain Buclaw committed d0edf91

Issue #191 - SEGV(gimple.c:2624) getting array ref of incomplete type.

Comments (0)

Files changed (2)

 IRState::pointerIntSum(tree ptr_node, tree idx_exp)
 {
     tree result_type_node = TREE_TYPE(ptr_node);
+    tree elem_type_node = TREE_TYPE(result_type_node);
     tree intop = idx_exp;
     tree size_exp;
 
 
     // %% TODO: real-not-long-double issues...
 
-    size_exp = size_in_bytes(TREE_TYPE(result_type_node)); // array element size
-    if (integer_zerop(size_exp) || // Test for void case...
-        integer_onep(size_exp))    // ...or byte case -- No need to multiply.
-    {
+    size_exp = size_in_bytes(elem_type_node); // array element size
+
+    if (integer_zerop(size_exp))
+    {   // Test for void case...
+        if (TYPE_MODE(elem_type_node) == TYPE_MODE(void_type_node))
+            intop = fold_convert(prod_result_type, intop);
+        else
+        {   // FIXME: should catch this earlier.
+            error("invalid use of incomplete type %qD", TYPE_NAME(elem_type_node));
+            result_type_node = error_mark_node;
+        }
+    }
+    else if (integer_onep(size_exp))
+    {   // ...or byte case -- No need to multiply.
         intop = fold_convert(prod_result_type, intop);
     }
     else
     {
-
         if (TYPE_PRECISION (TREE_TYPE (intop)) != TYPE_PRECISION (sizetype)
             || TYPE_UNSIGNED (TREE_TYPE (intop)) != TYPE_UNSIGNED (sizetype))
         {

d/d-gcc-includes.h

 #include "tree-dump.h"
 #include "tree-inline.h"
 #include "vec.h"
+
+#if D_GCC_VER == 43
+// Defined in tree-flow.h but gives us problems when trying to include it
+extern bool useless_type_conversion_p (tree, tree);
+#endif
+
 }
 
 // Define our own macro for handling mapped locations as