Iain Buclaw avatar Iain Buclaw committed 51d11a9

Issue #262 - ICE: weird segfault when -o option is used

Comments (0)

Files changed (5)

 int
 d_gcc_field_align(VarDeclaration * var, int known_align)
 {
-    static tree d_gcc_vfield = make_node(FIELD_DECL);
+    tree field = make_node(FIELD_DECL);
 
     /* %% stor-layout.c:
        Some targets (i.e. i386, VMS) limit struct field alignment
         return var->salign;
 
     // Work out the correct alignment for the field decl.
-    DECL_ALIGN(d_gcc_vfield) = known_align * BITS_PER_UNIT;
+    DECL_ALIGN(field) = known_align * BITS_PER_UNIT;
 
 #ifdef BIGGEST_FIELD_ALIGNMENT
-    DECL_ALIGN(d_gcc_vfield)
-        = MIN(DECL_ALIGN(d_gcc_vfield), (unsigned) BIGGEST_FIELD_ALIGNMENT);
+    DECL_ALIGN(field)
+        = MIN(DECL_ALIGN(field), (unsigned) BIGGEST_FIELD_ALIGNMENT);
 #endif
 #ifdef ADJUST_FIELD_ALIGN
     if (var->type->isTypeBasic())
     {
-        TREE_TYPE(d_gcc_vfield) = var->type->toCtype();
-        DECL_ALIGN(d_gcc_vfield)
-            = ADJUST_FIELD_ALIGN(d_gcc_vfield, DECL_ALIGN(d_gcc_vfield));
+        TREE_TYPE(field) = var->type->toCtype();
+        DECL_ALIGN(field)
+            = ADJUST_FIELD_ALIGN(field, DECL_ALIGN(field));
     }
 #endif
 
-    return DECL_ALIGN_UNIT(d_gcc_vfield);
+    if (d_free_list)
+        TREE_CHAIN(field) = d_free_list;
+    d_free_list = field;
+
+    return DECL_ALIGN_UNIT(field);
 }
 
 
     if (typesSame(exp_type, target_type))
         return exp;
 
+    if (isErrorMark(exp))
+        return exp;
+
     switch (ebtype->ty)
     {
         case Tdelegate:
 
 /* protect from garbage collection */
 extern GTY(()) tree d_keep_list;
+extern GTY((deletable)) tree d_free_list;
 
 #include "d-dmd-gcc.h"
 
     d_keep_list = tree_cons(NULL_TREE, t, d_keep_list);
 }
 
+// List of trees that we want to send to the garbage collector.
+tree d_free_list = NULL_TREE;
+
 #if D_GCC_VER >= 45
 tree d_eh_personality_decl;
 
 
 /* protect from garbage collection */
 extern GTY(()) tree d_keep_list;
+extern GTY((deletable)) tree d_free_list;
 
 #include "d-dmd-gcc.h"
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.