diff -r e8563dcaefca -r 56ebe2a31b5b stage3/remove_forward_dependencies.cc --- a/stage3/remove_forward_dependencies.cc Mon Apr 03 22:06:40 2017 +0100 +++ b/stage3/remove_forward_dependencies.cc Mon Apr 03 22:18:22 2017 +0100 @@ -209,10 +209,10 @@ /* Note too that circular references in derived datatypes is also not possible due to sytax! */ int initial_error_count = error_count; for (int i = 0; i < symbol->n; i++) - if ( (inserted_symbols.find(symbol->elements[i]) == inserted_symbols.end()) // if not copied to new AST - &&( (NULL != dynamic_cast (symbol->elements[i])) // and (is a FB - ||(NULL != dynamic_cast < function_declaration_c *>(symbol->elements[i])))) // or a Function) - STAGE3_ERROR(0, symbol->elements[i], symbol->elements[i], "POU (%s) contains a self-reference and/or belongs in a circular referencing loop", get_datatype_info_c::get_id_str(symbol->elements[i])); + if ( (inserted_symbols.find(symbol->get_element(i)) == inserted_symbols.end()) // if not copied to new AST + &&( (NULL != dynamic_cast (symbol->get_element(i))) // and (is a FB + ||(NULL != dynamic_cast < function_declaration_c *>(symbol->get_element(i))))) // or a Function) + STAGE3_ERROR(0, symbol->get_element(i), symbol->get_element(i), "POU (%s) contains a self-reference and/or belongs in a circular referencing loop", get_datatype_info_c::get_id_str(symbol->get_element(i))); if (error_count == initial_error_count) ERROR; // We were unable to determine which POUs contain the circular references!! } @@ -228,8 +228,8 @@ /* first insert all the derived datatype declarations, in the same order by which they are delcared in the original AST */ /* Since IEC 61131-3 does not allow FBs in arrays or structures, it is actually safe to place all the datatypes before all the POUs! */ for (int i = 0; i < symbol->n; i++) - if (NULL != dynamic_cast (symbol->elements[i])) - new_tree->add_element(symbol->elements[i]); + if (NULL != dynamic_cast (symbol->get_element(i))) + new_tree->add_element(symbol->get_element(i)); /* now do the POUs, in whatever order is necessary to guarantee no forward references. */ long long int old_tree_pou_count = pou_count_c::get_count(symbol); @@ -241,7 +241,7 @@ cycle_count++; prev_n = new_tree->n; current_code_generation_pragma = default_code_generation_pragma; - for (int i = 0; i < symbol->n; i++) symbol->elements[i]->accept(*this); + for (int i = 0; i < symbol->n; i++) symbol->get_element(i)->accept(*this); } while (prev_n != new_tree->n); // repeat while new elementns are still being added to the new AST if (old_tree_pou_count != pou_count_c::get_count(new_tree))