# HG changeset patch
# User Mario de Sousa <msousa@fe.up.pt>
# Date 1306515714 -3600
# Node ID 0cdf1410bcd8c5a06b901e6208e6f1d5672f4dc1
# Parent  d120740a6b588d01a6e7b82db9191306f05d95e0# Parent  15bf9ecb936d0f62a2075de3e3a4926e35c69afa
Merging with Edouard's version

diff -r 15bf9ecb936d -r 0cdf1410bcd8 stage4/generate_c/generate_c_st.cc
--- a/stage4/generate_c/generate_c_st.cc	Wed May 18 16:32:46 2011 +0200
+++ b/stage4/generate_c/generate_c_st.cc	Fri May 27 18:01:54 2011 +0100
@@ -155,6 +155,7 @@
 		symbol_c* value,
 		symbol_c* fb_symbol = NULL,
 		symbol_c* fb_value = NULL) {
+  
   unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
   if (vartype == search_var_instance_decl_c::external_vt) {
     symbolic_variable_c *variable = dynamic_cast<symbolic_variable_c *>(symbol);
@@ -185,10 +186,17 @@
   }
   else
     wanted_variablegeneration = complextype_base_vg;
+  
   symbol->accept(*this);
   s4o.print(",");
   wanted_variablegeneration = expression_vg;
   print_check_function(type, value, fb_value);
+  /* We need to call search_varfb_instance_type->get_vartype() again, as it may have been called
+   * again since we called it in the beginning of this print_setter() function.
+   * This make sure the call to search_varfb_instance_type->type_is_complex() will return
+   * the correct value regarding our 'symbol'.
+   */
+  search_varfb_instance_type->get_vartype(symbol);
   if (search_varfb_instance_type->type_is_complex()) {
     s4o.print(",");
     wanted_variablegeneration = complextype_suffix_vg;