# HG changeset patch # User Mario de Sousa # Date 1334586473 -3600 # Node ID 99aa36a77703f3631b9f6069bee3f97b81a37681 # Parent f915ab676d7efe8d29381ca6fc9dcbc33297dbf3 Add lvalue check for non formal function invocations. diff -r f915ab676d7e -r 99aa36a77703 stage3/lvalue_check.cc --- a/stage3/lvalue_check.cc Mon Apr 16 15:17:24 2012 +0100 +++ b/stage3/lvalue_check.cc Mon Apr 16 15:27:53 2012 +0100 @@ -159,9 +159,45 @@ /* check whether all values passed to OUT or IN_OUT parameters are legal lvalues. */ +/* + * All parameters being passed to the called function MUST be in the parameter list to which f_call points to! + * This means that, for non formal function calls in IL, de current (default value) must be artificially added to the + * beginning of the parameter list BEFORE calling handle_function_call(). + */ +#include /* required for strcmp() */ void lvalue_check_c::check_nonformal_call(symbol_c *f_call, symbol_c *f_decl) { - /* TODO */ -} + symbol_c *call_param_value; + identifier_c *param_name; + function_param_iterator_c fp_iterator(f_decl); + function_call_param_iterator_c fcp_iterator(f_call); + + /* Iterating through the non-formal parameters of the function call */ + while((call_param_value = fcp_iterator.next_nf()) != NULL) { + /* Iterate to the next parameter of the function being called. + * Get the name of that parameter, and ignore if EN or ENO. + */ + do { + param_name = fp_iterator.next(); + /* If there is no other parameter declared, then we are passing too many parameters... */ + /* This error should have been caught in data type verification, so we simply abandon our check! */ + if(param_name == NULL) return; + } while ((strcmp(param_name->value, "EN") == 0) || (strcmp(param_name->value, "ENO") == 0)); + + /* Find the corresponding parameter in function declaration, and it's direction (IN, OUT, IN_OUT) */ + function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); + + /* We only check if 'call_param_value' is a valid lvalue if the value is being passed + * to a valid paramater of the function being called, and that parameter is either OUT or IN_OUT. + */ + if ((param_name != NULL) && ((function_param_iterator_c::direction_out == param_direction) || (function_param_iterator_c::direction_inout == param_direction))) { + verify_is_lvalue(call_param_value); + } + } +} + + + + /* check whether all values passed to OUT or IN_OUT parameters are legal lvalues. */