# HG changeset patch # User mjsousa # Date 1413716016 -3600 # Node ID 887e7d90445a2e834018e8111a0cac5d7f343705 # Parent 0f7bcc1605680d1a1f2a676e8138b6b881b0e683 Fix bug with multple dereferencing (bool_var := bool_ptr_ptr^^;) diff -r 0f7bcc160568 -r 887e7d90445a stage3/narrow_candidate_datatypes.cc --- a/stage3/narrow_candidate_datatypes.cc Sun Oct 19 08:36:49 2014 +0100 +++ b/stage3/narrow_candidate_datatypes.cc Sun Oct 19 11:53:36 2014 +0100 @@ -1381,13 +1381,13 @@ /* SYM_REF1(deref_expression_c, exp) --> an extension to the IEC 61131-3 standard - based on the IEC 61131-3 v3 standard. Returns address of the varible! */ void *narrow_candidate_datatypes_c::visit(deref_expression_c *symbol) { for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) { - /* Determine whether the datatype is a ref_spec_c, as this is the class used as the */ - /* canonical/base datatype of REF_TO types (see search_base_type_c ...) */ - ref_spec_c *ref_spec = dynamic_cast(symbol->exp->candidate_datatypes[i]); - - if ((NULL != ref_spec) && get_datatype_info_c::is_type_equal(ref_spec->type_name, symbol->datatype)) + symbol_c *typ = symbol->exp->candidate_datatypes[i]; + symbol_c *ref = get_datatype_info_c::get_ref_to(typ); + if ( (get_datatype_info_c::is_ref_to(typ)) + && (get_datatype_info_c::is_type_equal(search_base_type_c::get_basetype_decl(ref), symbol->datatype)) + ) /* if it points to the required datatype for symbol, then that is the required datatype for symbol->exp */ - symbol->exp->datatype = ref_spec; + symbol->exp->datatype = typ; } symbol->exp->accept(*this); @@ -1398,13 +1398,13 @@ /* SYM_REF1(deref_operator_c, exp) --> an extension to the IEC 61131-3 standard - based on the IEC 61131-3 v3 standard. Returns address of the varible! */ void *narrow_candidate_datatypes_c::visit(deref_operator_c *symbol) { for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) { - /* Determine whether the datatype is a ref_spec_c, as this is the class used as the */ - /* canonical/base datatype of REF_TO types (see search_base_type_c ...) */ - ref_spec_c *ref_spec = dynamic_cast(symbol->exp->candidate_datatypes[i]); - - if ((NULL != ref_spec) && get_datatype_info_c::is_type_equal(ref_spec->type_name, symbol->datatype)) + symbol_c *typ = symbol->exp->candidate_datatypes[i]; + symbol_c *ref = get_datatype_info_c::get_ref_to(typ); + if ( (get_datatype_info_c::is_ref_to(typ)) + && (get_datatype_info_c::is_type_equal(search_base_type_c::get_basetype_decl(ref), symbol->datatype)) + ) /* if it points to the required datatype for symbol, then that is the required datatype for symbol->exp */ - symbol->exp->datatype = ref_spec; + symbol->exp->datatype = typ; } symbol->exp->accept(*this);