F diff --git a/src/backend/print/print.c b/src/backend/print/print.c --- a/src/backend/print/print.c +++ b/src/backend/print/print.c}void print_function_expression_tree(FILE *out,struct AST_Function_Expression *function_call){- struct Queue_Node *it;+ size_t i;print_ast(out,(struct AST*)function_call->id);fprintf(out,"(");- if(function_call->arguments.size>0)+ if(function_call->number_of_arguments>0){- fprintf(out,"\n");- for(it=function_call->arguments.first;it!=function_call->arguments.last;it=it->prev)+ for(i=0;i<function_call->number_of_arguments;++i){- print_ast(out,(struct AST*)(struct AST*)(it->data));- fprintf(out,",\n");+ print_ast(out,(struct AST*)function_call->arg_list[i]);+ if(i!=function_call->number_of_arguments-1)+ fprintf(out,",");}- if(it!=NULL)- {- print_ast(out,(struct AST*)(struct AST*)(it->data));- }-}fprintf(out,")");}F diff --git a/src/frontend/parse/parse_declaration.c b/src/frontend/parse/parse_declaration.c --- a/src/frontend/parse/parse_declaration.c +++ b/src/frontend/parse/parse_declaration.c/*check if this is a function definition*/if(parse_function_definitions && get_and_check(translation_data,KW_OPEN_CURLY)){+ struct Type_Function *function_type;+ function_type=(struct Type_Function*)((struct Denoted_Function*)hold)->type;((struct Denoted_Function*)hold) ->body=- (struct AST_Compound_Statement*)parse_finish_compound_statement(translation_data,scope);+ (struct AST_Compound_Statement*)parse_finish_compound_statement(translation_data,(struct Scope*)function_type->function_prototype_scope);Queue_Push(where_to_push,get_function_definition_tree(scope,(struct Denoted_Function*)hold));Scope_Push(scope,hold,translation_data);break;F diff --git a/src/frontend/parse/parse_expression.c b/src/frontend/parse/parse_expression.c --- a/src/frontend/parse/parse_expression.c +++ b/src/frontend/parse/parse_expression.cstruct AST_Function_Expression* parse_arglist(struct Translation_Data *translation_data,struct Scope *scope,struct AST_Expression* id){struct AST_Function_Expression *ret;+ struct AST_Expression *hold_expression;+ struct Queue arg_list;++ Queue_Init(&arg_list);- ret=get_function_expression_tree(id,scope);- ret->id=id;if(get_and_check(translation_data,KW_CLOSE_NORMAL)){- return ret;+ return get_function_expression_tree(id,&arg_list,translation_data);}+do{- Queue_Push(&ret->arguments,parse_assignment_expression(translation_data,scope));- } while(get_and_check(translation_data,KW_COMMA));+ hold_expression=parse_assignment_expression(translation_data,scope);+ if(hold_expression==NULL)+ {+ while(arg_list.size>0)+ delete_ast((struct AST*)Queue_Pop(&arg_list));+ push_translation_error("error in argument list in function call expression",translation_data);+ return NULL;+ }+ Queue_Push(&arg_list,hold_expression);+ }while(get_and_check(translation_data,KW_COMMA));++ ret=get_function_expression_tree(id,&arg_list,translation_data);+ assert(arg_list.size==0);+if(get_and_check(translation_data,KW_CLOSE_NORMAL)){return ret;}else{push_translation_error("expected ')' here",translation_data);- return (struct AST_Function_Expression*)get_error_tree((struct AST*)ret);+ delete_ast((struct AST*)ret);+ return NULL;}}F diff --git a/src/semantics/ast.c b/src/semantics/ast.c --- a/src/semantics/ast.c +++ b/src/semantics/ast.creturn ret;}- struct AST_Function_Expression* get_function_expression_tree(struct AST_Expression *id,struct Scope *scope)+ struct AST_Function_Expression* get_function_expression_tree(struct AST_Expression *id,struct Queue *arg_list,struct Translation_Data *translation_data){struct AST_Function_Expression *ret;+ struct Type_Function *id_type;+ size_t i;++ id_type=(struct Type_Function*)extract_expresion_value_type(id->value,translation_data);ret=malloc(sizeof(struct AST_Function_Expression));ret->type=OP_FUNCTION;+ ret->value=get_expression_value_rvalue(get_temp_object(id_type->return_type));ret->id=id;- Queue_Init(&ret->arguments);- return ret;+ ret->number_of_arguments=arg_list->size;++ ret->arg_list=calloc(ret->number_of_arguments,sizeof(struct AST_Expression*));+ for(i=0;i<ret->number_of_arguments;++i)+ {+ assert(arg_list->size>0);+ ret->arg_list[i]=(struct AST_Expression*)Queue_Pop(arg_list);+ }+ assert(arg_list->size==0);+ if(constraint_check_function_expression(ret,translation_data))+ {+ return ret;+ }+ else+ {+ delete_ast((struct AST*)ret);+ push_translation_error("constraint check violation in function call expression",translation_data);+ return NULL;+ }}struct AST_Unary_Expression* get_unary_expression_tree(struct AST_Expression *operand,struct Expression_Value *value,enum AST_Type type){void delete_ast_function_expression(struct AST_Function_Expression *function_expression){struct Queue_Node *it;+ size_t i;+if(function_expression->id!=NULL)delete_ast((struct AST*)function_expression->id);- while(function_expression->arguments.size>0)- delete_ast(Queue_Pop(&function_expression->arguments));+ if(function_expression->number_of_arguments!=0)+ {+ for(i=0;i<function_expression->number_of_arguments;++i)+ {+ delete_ast((struct AST*)function_expression->arg_list[i]);+ }+ free(function_expression->arg_list);+ }free(function_expression);F diff --git a/src/semantics/ast.h b/src/semantics/ast.h --- a/src/semantics/ast.h +++ b/src/semantics/ast.hstruct Expression_Value *value;struct AST_Expression *id;- /*queue of astrees*/- struct Queue arguments;++ size_t number_of_arguments;+ struct AST_Expression **arg_list;};struct AST_Constantstruct AST_Binary_Expression* get_struct_union_member_trough_ptr_tree(struct AST_Expression *left,struct token *id,struct Translation_Data *translation_data);struct AST_Conditional_Expression* get_conditional_expression_tree(struct AST_Expression *left,struct AST_Expression *center,struct AST_Expression *right,struct Translation_Data *translation_data);- struct AST_Function_Expression* get_function_expression_tree(struct AST_Expression *id,struct Scope *scope);+ struct AST_Function_Expression* get_function_expression_tree(struct AST_Expression *id,struct Queue *arg_list,struct Translation_Data *translation_data);struct AST_Unary_Expression* get_unary_expression_tree(struct AST_Expression *operand,struct Expression_Value *value,enum AST_Type type);struct AST_Unary_Expression* get_indirection_expression_tree(struct AST_Expression *operand,struct Translation_Data *translation_data);F diff --git a/src/semantics/value/constraints.c b/src/semantics/value/constraints.c --- a/src/semantics/value/constraints.c +++ b/src/semantics/value/constraints.c}}}- char constraint_check_function_expression(struct AST_Expression *id,struct Scope *scope,struct Translation_Data *translation_data)+ char constraint_check_function_expression(struct AST_Function_Expression *proposed_function,struct Translation_Data *translation_data){+ struct Type *expected_argument_type;+ struct Type *given_argument_type;+ struct Type_Function *proposed_function_type;+ size_t i;++ proposed_function_type=(struct Type_Function*)extract_expresion_value_type(proposed_function->id->value,translation_data);+ if(proposed_function_type->specifier!=TS_FUNC)+ {+ push_translation_error("is not a function",translation_data);+ return 0;+ }++ if(proposed_function_type->number_of_arguments!=proposed_function->number_of_arguments)+ {+ push_translation_error("mismatching number of arguments",translation_data);+ return 0;+ }++ for(i=0;i<proposed_function->number_of_arguments;++i)+ {+ expected_argument_type=proposed_function_type->arguments[i]->object->type;+ given_argument_type=extract_expresion_value_type(proposed_function->arg_list[i]->value,translation_data);+ if(!types_are_compatible_unqualified(expected_argument_type,given_argument_type))+ {+ push_translation_error("incompatible types of argument",translation_data);+ return 0;+ }+ }return 1;}char constraint_check_indirection_expression(struct AST_Expression *operand,struct Translation_Data *translation_data)F diff --git a/src/semantics/value/constraints.h b/src/semantics/value/constraints.h --- a/src/semantics/value/constraints.h +++ b/src/semantics/value/constraints.hchar constraint_check_struct_union_member_expression(struct AST_Expression *left,struct token *id,struct Translation_Data *translation_data);char constraint_check_struct_union_member_trough_ptr_expression(struct AST_Expression *left,struct token *id,struct Translation_Data *translation_data);char constraint_check_conditional_expression(struct AST_Expression *left,struct AST_Expression *center,struct AST_Expression *right,struct Translation_Data *translation_data);- char constraint_check_function_expression(struct AST_Expression *id,struct Scope *scope,struct Translation_Data *translation_data);+ char constraint_check_function_expression(struct AST_Function_Expression *proposed_function,struct Translation_Data *translation_data);char constraint_check_indirection_expression(struct AST_Expression *operand,struct Translation_Data *translation_data);char constraint_check_address_expression(struct AST_Expression *operand,struct Translation_Data *translation_data);char constraint_check_sizeof_by_type(struct Type *type);