Print error message when FB/Struct initial value contains other strcuts/FB/arrays (not yet supported by C code generator).
authorMario de Sousa <msousa@fe.up.pt>
Sun, 16 Apr 2017 08:45:56 +0100
changeset 1048 37966f855bed
parent 1047 34b733cb6641
child 1049 4d7183013481
Print error message when FB/Struct initial value contains other strcuts/FB/arrays (not yet supported by C code generator).
stage4/generate_c/generate_c_vardecl.cc
--- a/stage4/generate_c/generate_c_vardecl.cc	Wed Apr 05 13:21:50 2017 +0100
+++ b/stage4/generate_c/generate_c_vardecl.cc	Sun Apr 16 08:45:56 2017 +0100
@@ -976,6 +976,11 @@
       for (int i = 0; i < init_list->n; i++) {
         structure_element_initialization_c *init_list_elem = dynamic_cast<structure_element_initialization_c *>(init_list->get_element(i));
         if (NULL == init_list_elem) ERROR;
+        if (!get_datatype_info_c::is_ANY_ELEMENTARY(init_list_elem->value->datatype)) {
+          STAGE4_ERROR(init_list_elem, init_list_elem, 
+                       "C code generation does not yet support initializing FB/structures with non-elementary values.");
+          ERROR;
+        }
         s4o.print("\n");
         s4o.print(s4o.indent_spaces);
         s4o.print(INIT_VAR);