Fix bug in code generated for MUL function
authorlaurent
Fri, 24 Feb 2012 18:16:56 +0100
changeset 407 2d77f0f77773
parent 406 6381589697ff
child 408 34a5571c859c
child 499 58d0c3b3c53b
Fix bug in code generated for MUL function
stage3/visit_expression_type.cc
--- a/stage3/visit_expression_type.cc	Fri Feb 24 14:16:51 2012 +0100
+++ b/stage3/visit_expression_type.cc	Fri Feb 24 18:16:56 2012 +0100
@@ -1069,6 +1069,7 @@
   symbol_c *return_data_type = NULL;
   symbol_c* fdecl_return_type;
   symbol_c* overloaded_data_type = NULL;
+  int extensible_param_count = -1;
   symbol->called_function_declaration = NULL;
 
   /* First find the declaration of the function being called! */
@@ -1100,20 +1101,21 @@
       fdecl_return_type = base_type(f_decl->type_name);
 
       if (symbol->called_function_declaration == NULL) {
-          /* Store the pointer to the declaration of the function being called.
-           * This data will be used by stage 4 to call the correct function.
-           * Mostly needed to disambiguate overloaded functions...
-           * See comments in absyntax.def for more details
+        /* Store the pointer to the declaration of the function being called.
+         * This data will be used by stage 4 to call the correct function.
+         * Mostly needed to disambiguate overloaded functions...
+         * See comments in absyntax.def for more details
          */
         symbol->called_function_declaration = f_decl;
-
-          /* determine the base data type returned by the function being called... */
-          return_data_type = fdecl_return_type;
-        }
-        else if (typeid(*return_data_type) != typeid(*fdecl_return_type)){
-          return_data_type = common_literal(return_data_type, fdecl_return_type);
-          overloaded_data_type = overloaded_return_type(return_data_type);
-        }
+        extensible_param_count = symbol->extensible_param_count;
+
+        /* determine the base data type returned by the function being called... */
+        return_data_type = fdecl_return_type;
+      }
+      else if (typeid(*return_data_type) != typeid(*fdecl_return_type)){
+        return_data_type = common_literal(return_data_type, fdecl_return_type);
+        overloaded_data_type = overloaded_return_type(return_data_type);
+      }
       
       if (NULL == return_data_type) ERROR;
     }
@@ -1137,6 +1139,7 @@
            * See comments in absyntax.def for more details
            */
           symbol->called_function_declaration = f_decl;
+          extensible_param_count = symbol->extensible_param_count;
         }
       }
     }
@@ -1147,6 +1150,7 @@
     STAGE3_ERROR(symbol, symbol, "Call to an overloaded function with invalid parameter type.");
   }
   else {
+    symbol->extensible_param_count = extensible_param_count;
     /* set the new data type of the default variable for the following verifications... */
     il_default_variable_type = return_data_type;
   }
@@ -1273,6 +1277,7 @@
   symbol_c *return_data_type = NULL;
   symbol_c* fdecl_return_type;
   symbol_c *overloaded_data_type = NULL;
+  int extensible_param_count = -1;
   symbol->called_function_declaration = NULL;
 
   function_symtable_t::iterator lower = function_symtable.lower_bound(symbol->function_name);
@@ -1315,6 +1320,7 @@
          * See comments in absyntax.def for more details
          */
         symbol->called_function_declaration = f_decl;
+        extensible_param_count = symbol->extensible_param_count;
 
         /* determine the base data type returned by the function being called... */
         return_data_type = fdecl_return_type;
@@ -1348,6 +1354,7 @@
            * See comments in absyntax.def for more details
            */
           symbol->called_function_declaration = f_decl;
+          extensible_param_count = symbol->extensible_param_count;
         }
       }
     }
@@ -1358,6 +1365,7 @@
     STAGE3_ERROR(symbol, symbol, "Call to an overloaded function with invalid parameter type.");
   }
   else {
+    symbol->extensible_param_count = extensible_param_count;
     /* the data type of the data returned by the function, and stored in the il default variable... */
     il_default_variable_type = return_data_type;
   }
@@ -2119,6 +2127,7 @@
   symbol_c* return_data_type;
   symbol_c* fdecl_return_type;
   symbol_c* overloaded_data_type = NULL;
+  int extensible_param_count = -1;
   symbol->called_function_declaration = NULL;
 
   function_symtable_t::iterator second = lower;
@@ -2160,6 +2169,7 @@
          * See comments in absyntax.def for more details
          */
         symbol->called_function_declaration = f_decl;
+        extensible_param_count = symbol->extensible_param_count;
 
         /* determine the base data type returned by the function being called... */
         return_data_type = fdecl_return_type;
@@ -2190,13 +2200,16 @@
            * See comments in absyntax.def for more details
            */
           symbol->called_function_declaration = f_decl;
+          extensible_param_count = symbol->extensible_param_count;
         }
       }
     }
   }
 
-  if (return_data_type != NULL)
-    return return_data_type;
+  if (return_data_type != NULL) {
+	symbol->extensible_param_count = extensible_param_count;
+	return return_data_type;
+  }
 
   /* No compatible function was found for this function call */
   STAGE3_ERROR(symbol, symbol, "Call to an overloaded function with invalid parameter type.");