Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
authorlaurent
Tue, 21 Feb 2012 22:31:38 +0100
changeset 405 7b5d67d1aeef
parent 404 ff3313e22883
child 406 6381589697ff
child 497 5b7a0d9838d2
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
stage4/generate_c/generate_c_il.cc
stage4/generate_c/generate_c_st.cc
--- a/stage4/generate_c/generate_c_il.cc	Tue Feb 21 22:28:57 2012 +0100
+++ b/stage4/generate_c/generate_c_il.cc	Tue Feb 21 22:31:38 2012 +0100
@@ -472,12 +472,18 @@
     		symbol_c* fb_symbol = NULL,
     		symbol_c* fb_value = NULL,
     		bool negative = false) {
-      unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
-      bool type_is_complex = search_varfb_instance_type->type_is_complex();
-      if (vartype == search_var_instance_decl_c::external_vt)
-        s4o.print(SET_EXTERNAL);
-      else if (vartype == search_var_instance_decl_c::located_vt)
-        s4o.print(SET_LOCATED);
+
+      bool type_is_complex = false;
+      if (fb_symbol == NULL) {
+        unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
+        type_is_complex = search_varfb_instance_type->type_is_complex();
+        if (vartype == search_var_instance_decl_c::external_vt)
+          s4o.print(SET_EXTERNAL);
+        else if (vartype == search_var_instance_decl_c::located_vt)
+          s4o.print(SET_LOCATED);
+        else
+          s4o.print(SET_VAR);
+      }
       else
         s4o.print(SET_VAR);
       s4o.print("(");
--- a/stage4/generate_c/generate_c_st.cc	Tue Feb 21 22:28:57 2012 +0100
+++ b/stage4/generate_c/generate_c_st.cc	Tue Feb 21 22:31:38 2012 +0100
@@ -170,14 +170,19 @@
 		symbol_c* fb_symbol = NULL,
 		symbol_c* fb_value = NULL) {
   
-  unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
-  bool type_is_complex = search_varfb_instance_type->type_is_complex();
-  if (vartype == search_var_instance_decl_c::external_vt)
-    s4o.print(SET_EXTERNAL);
-  else if (vartype == search_var_instance_decl_c::located_vt)
-    s4o.print(SET_LOCATED);
+  bool type_is_complex = false;
+  if (fb_symbol == NULL) {
+	unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
+    type_is_complex = search_varfb_instance_type->type_is_complex();
+    if (vartype == search_var_instance_decl_c::external_vt)
+      s4o.print(SET_EXTERNAL);
+    else if (vartype == search_var_instance_decl_c::located_vt)
+      s4o.print(SET_LOCATED);
+    else
+      s4o.print(SET_VAR);
+  }
   else
-    s4o.print(SET_VAR);
+	s4o.print(SET_VAR);
   s4o.print("(");
 
   if (fb_symbol != NULL) {