139 int extensible_parameter_highest_index = -1; |
139 int extensible_parameter_highest_index = -1; |
140 identifier_c *extensible_parameter_name; |
140 identifier_c *extensible_parameter_name; |
141 unsigned int i; |
141 unsigned int i; |
142 |
142 |
143 if (NULL != ext_parm_count) *ext_parm_count = -1; |
143 if (NULL != ext_parm_count) *ext_parm_count = -1; |
144 |
|
145 /* Iterating through the formal parameters of the function call */ |
144 /* Iterating through the formal parameters of the function call */ |
146 while((call_param_name = fcp_iterator.next_f()) != NULL) { |
145 while((call_param_name = fcp_iterator.next_f()) != NULL) { |
147 |
146 |
148 /* Obtaining the value being passed in the function call */ |
147 /* Obtaining the value being passed in the function call */ |
149 call_param_value = fcp_iterator.get_current_value(); |
148 call_param_value = fcp_iterator.get_current_value(); |
1023 void *narrow_candidate_datatypes_c::visit(function_invocation_c *symbol) { |
1022 void *narrow_candidate_datatypes_c::visit(function_invocation_c *symbol) { |
1024 int ext_parm_count; |
1023 int ext_parm_count; |
1025 |
1024 |
1026 /* set the called_function_declaration. */ |
1025 /* set the called_function_declaration. */ |
1027 symbol->called_function_declaration = NULL; |
1026 symbol->called_function_declaration = NULL; |
|
1027 #if 0 |
1028 if (symbol->candidate_datatypes.size() == 1) { |
1028 if (symbol->candidate_datatypes.size() == 1) { |
1029 /* If only one possible called function, then that is the function to call! |
1029 /* If only one possible called function, then that is the function to call! |
1030 * In this case we ignore the symbol->datatype value (that may even be NULL). |
1030 * In this case we ignore the symbol->datatype value (that may even be NULL). |
1031 * This helps in identifying potential errors in the expressions used inside this function call |
1031 * This helps in identifying potential errors in the expressions used inside this function call |
1032 * even if there is a previous error, allowing us to make a more thorough analysis of the semantics |
1032 * even if there is a previous error, allowing us to make a more thorough analysis of the semantics |
1035 * otherwise we have a bug in our stage3 code! |
1035 * otherwise we have a bug in our stage3 code! |
1036 */ |
1036 */ |
1037 symbol->called_function_declaration = symbol->candidate_functions[0]; |
1037 symbol->called_function_declaration = symbol->candidate_functions[0]; |
1038 if ((NULL != symbol->datatype) && (!is_type_equal(symbol->candidate_datatypes[0], symbol->datatype))) |
1038 if ((NULL != symbol->datatype) && (!is_type_equal(symbol->candidate_datatypes[0], symbol->datatype))) |
1039 ERROR; |
1039 ERROR; |
1040 } |
1040 } else |
1041 else { |
1041 #endif |
|
1042 { |
1042 /* set the called_function_declaration taking into account the datatype that we need to return */ |
1043 /* set the called_function_declaration taking into account the datatype that we need to return */ |
1043 symbol->called_function_declaration = NULL; |
|
1044 for(unsigned int i = 0; i < symbol->candidate_datatypes.size(); i++) { |
1044 for(unsigned int i = 0; i < symbol->candidate_datatypes.size(); i++) { |
1045 if (is_type_equal(symbol->candidate_datatypes[i], symbol->datatype)) { |
1045 if (is_type_equal(symbol->candidate_datatypes[i], symbol->datatype)) { |
1046 symbol->called_function_declaration = symbol->candidate_functions[i]; |
1046 symbol->called_function_declaration = symbol->candidate_functions[i]; |
1047 break; |
1047 break; |
1048 } |
1048 } |
1050 } |
1050 } |
1051 /* NOTE: If we can't figure out the declaration of the function being called, this is not |
1051 /* NOTE: If we can't figure out the declaration of the function being called, this is not |
1052 * necessarily an internal compiler error. It could be because the symbol->datatype is NULL |
1052 * necessarily an internal compiler error. It could be because the symbol->datatype is NULL |
1053 * (because the ST code being analysed has an error _before_ this function invocation). |
1053 * (because the ST code being analysed has an error _before_ this function invocation). |
1054 * However, we don't just give, up, we carry on recursivly analysing the code, so as to be |
1054 * However, we don't just give, up, we carry on recursivly analysing the code, so as to be |
1055 * able to print out any error messages related to underlying code that could be partially correct. |
1055 * able to print out any error messages related to the parameters being passed in this function |
|
1056 * invocation. |
1056 */ |
1057 */ |
1057 /* if (NULL == symbol->called_function_declaration) ERROR; */ |
1058 /* if (NULL == symbol->called_function_declaration) ERROR; */ |
1058 |
1059 |
|
1060 if (symbol->candidate_datatypes.size() == 1) { |
|
1061 /* If only one function declaration, then we use that (even if symbol->datatypes == NULL) |
|
1062 * so we can check for errors in the expressions used to pass parameters in this |
|
1063 * function invocation. |
|
1064 */ |
|
1065 symbol->called_function_declaration = symbol->candidate_functions[0]; |
|
1066 } |
|
1067 /* If an overloaded function is being invoked, and we cannot determine which version to use, |
|
1068 * then we can not meaningfully verify the expressions used inside that function invocation. |
|
1069 * We simply give up! |
|
1070 */ |
|
1071 if (NULL == symbol->called_function_declaration) { |
|
1072 printf("giving up!\n"); |
|
1073 return NULL; |
|
1074 } |
|
1075 |
1059 if (NULL != symbol->nonformal_param_list) narrow_nonformal_call(symbol, symbol->called_function_declaration, &ext_parm_count); |
1076 if (NULL != symbol->nonformal_param_list) narrow_nonformal_call(symbol, symbol->called_function_declaration, &ext_parm_count); |
1060 if (NULL != symbol-> formal_param_list) narrow_formal_call(symbol, symbol->called_function_declaration, &ext_parm_count); |
1077 if (NULL != symbol-> formal_param_list) narrow_formal_call(symbol, symbol->called_function_declaration, &ext_parm_count); |
1061 symbol->extensible_param_count = ext_parm_count; |
1078 symbol->extensible_param_count = ext_parm_count; |
1062 |
1079 |
1063 return NULL; |
1080 return NULL; |