Bug with structure of structure fixed
authorlbessard
Fri, 09 Jan 2009 17:05:24 +0100
changeset 164 a0679c78143a
parent 163 61f65dd6eeb9
child 165 83963465b773
Bug with structure of structure fixed
stage4/generate_c/generate_c_typedecl.cc
stage4/generate_c/generate_c_vardecl.cc
--- a/stage4/generate_c/generate_c_typedecl.cc	Sun Jan 04 17:23:06 2009 +0100
+++ b/stage4/generate_c/generate_c_typedecl.cc	Fri Jan 09 17:05:24 2009 +0100
@@ -538,9 +538,9 @@
 //SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization)
 void *visit(initialized_structure_c *symbol) {
   TRACE("initialized_structure_c");
-  fprintf(stderr, "initialized_structure_c\n");
-  
-  symbol->structure_type_name->accept(*this);
+  
+  symbol->structure_type_name->accept(*basedecl);
+  
   return NULL;
 }
 
--- a/stage4/generate_c/generate_c_vardecl.cc	Sun Jan 04 17:23:06 2009 +0100
+++ b/stage4/generate_c/generate_c_vardecl.cc	Fri Jan 09 17:05:24 2009 +0100
@@ -604,12 +604,23 @@
         
         if (element_value == NULL) ERROR;
         
-        element_value->accept(*this);
+        structure_element_initialization_list_c *structure_element_initialization_list = dynamic_cast<structure_element_initialization_list_c *>(element_value);
+            
+        if (structure_element_initialization_list != NULL) {
+          generate_c_structure_initialization_c *structure_initialization = new generate_c_structure_initialization_c(&s4o);
+          structure_initialization->set_variable_prefix(get_variable_prefix());
+          structure_initialization->init_structure_default(current_element_type);
+          structure_initialization->current_mode = generate_c_structure_initialization_c::initializationvalue_sm;
+          element_value->accept(*structure_initialization);
+          delete structure_initialization;
+        }
+        else
+          element_value->accept(*this);
       }
       s4o.print("}");
       return NULL;
     }
-
+    
     /* helper symbol for array_initialization */
     /* array_initial_elements_list ',' array_initial_elements */
     void *visit(array_initial_elements_list_c *symbol) {