F diff --git a/src/backend/text/print/print.c b/src/backend/text/print/print.c
--- a/src/backend/text/print/print.c
+++ b/src/backend/text/print/print.c
if(func->number_of_arguments==0)
return;
- print_denoted(compile_data,(struct Denoted*)func->arguments[0]);
+ print_denoted_argument(compile_data,func->arguments[0]);
for(i=1;i<func->number_of_arguments;++i)
{
append_to_last_line(gstr_to_heap(", "),compile_data->lines);
print_denoted(compile_data,(struct Denoted*)func->arguments[i]);
}
}
+ void print_denoted_argument(struct Compile_Data_Print *compile_data,struct Denoted_Object *denoted)
+ {
+ append_to_last_line(gstr_to_heap("denoted object "),compile_data->lines);
+ if(denoted->id)
+ print_token(compile_data,denoted->id);
+ print_object(compile_data,denoted->object);
+ append_to_last_line(gstr_to_heap(" is a"),compile_data->lines);
+ print_type(compile_data,denoted->object->type,1);
+ return;
+ }
void print_type_qualifier(struct Compile_Data_Print *compile_data,struct Type *type)
{
if(type_is_constant(type))
F diff --git a/src/backend/text/print/print.h b/src/backend/text/print/print.h
--- a/src/backend/text/print/print.h
+++ b/src/backend/text/print/print.h
void print_goto_statement_tree(struct Compile_Data_Print *compile_data,struct AST_Goto_Statement *got);
void print_type(struct Compile_Data_Print *compile_data,struct Type *type,char print_struct_union);
void print_denoted(struct Compile_Data_Print *compile_data,struct Denoted *denoted);
+ void print_denoted_argument(struct Compile_Data_Print *compile_data,struct Denoted_Object *denoted);
void print_list_of_denoted(struct Compile_Data_Print *compile_data,struct Queue *denoted);
void print_enumeration(struct Compile_Data_Print *compile_data,struct Enum *enumeration);
void print_struct_union(struct Compile_Data_Print *compile_data,struct Struct_Union *struct_union);
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.c
do
{
hold_expression=parse_assignment_expression(translation_data,scope);
- /*
- * COMENTED THIS WHILE TRYING TO REMOVE NULL RETURNS
- 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));
F diff --git a/src/semantics/ast.c b/src/semantics/ast.c
--- a/src/semantics/ast.c
+++ b/src/semantics/ast.c
size_t i;
if(id->type==ERROR)
- id_type=(struct Type_Function*)get_type_error(NULL);
- else
+ return (struct AST_Function_Expression*)get_error_tree((struct AST*)id);
+ else
+ {
id_type=(struct Type_Function*)extract_expresion_value_type(id->value,translation_data);
+ if(type_is_pointer_to_function((struct Type*)id_type))
+ id_type=(struct Type_Function*)((struct Type_Pointer*)id_type)->points_to;
+ else
+ return (struct AST_Function_Expression*)get_error_tree((struct AST*)id);
+ }
ret=malloc(sizeof(struct AST_Function_Expression));
ret->type=OP_FUNCTION;
return ret;
}
- struct AST_Designator* get_designator_tree(struct token *id,struct Scope* scope,struct Translation_Data *translation_data)
+ struct AST_Expression* get_designator_tree(struct token *id,struct Scope* scope,struct Translation_Data *translation_data)
{
struct AST_Designator *ret;
struct Denoted *hold_denoted;
{
push_translation_error("using undeclared id - %t, in expression",translation_data,id);
free(ret);
- return (struct AST_Designator*)get_error_tree(NULL);
+ return (struct AST_Expression*)get_error_tree(NULL);
}else
{
switch(hold_denoted->denotation)
break;
case DT_Function:
ret->value=get_expression_value_function_designator((struct Denoted_Function*)hold_denoted);
- break;
+ ret->id=id;
+ return (struct AST_Expression*)get_address_expression_tree((struct AST_Expression*)ret,translation_data);/*BEWARE*/
}
}
ret->id=id;
- return ret;
+ return (struct AST_Expression*)ret;
}
struct AST_Designator* get_designator_tree_from_denoted_object(struct Denoted_Object *object,struct Translation_Data *translation_data)
F diff --git a/src/semantics/ast.h b/src/semantics/ast.h
--- a/src/semantics/ast.h
+++ b/src/semantics/ast.h
struct AST_Constant* get_constant_tree(struct Expression_Value *value);
struct AST_String_Literal* get_string_literal_tree(struct Expression_Value *value);
- struct AST_Designator* get_designator_tree(struct token *id,struct Scope *scope,struct Translation_Data *translation_data);
+ struct AST_Expression* get_designator_tree(struct token *id,struct Scope* scope,struct Translation_Data *translation_data);
struct AST_Designator* get_designator_tree_from_denoted_object(struct Denoted_Object *object,struct Translation_Data *translation_data);
struct AST_Designator* get_struct_union_member_tree_designator(struct token *id,struct Normal_Scope *inner_scope,struct Translation_Data *translation_data);
F diff --git a/src/semantics/constraints/expression_constraints.c b/src/semantics/constraints/expression_constraints.c
--- a/src/semantics/constraints/expression_constraints.c
+++ b/src/semantics/constraints/expression_constraints.c
{
struct Type *expected_argument_type;
struct Type *given_argument_type;
+ struct Type_Pointer *proposed_function_pointer_type;
struct Type_Function *proposed_function_type;
size_t i;
if(proposed_function->type==ERROR || proposed_function->id->type==ERROR)
return 0;
- proposed_function_type=(struct Type_Function*)extract_expresion_value_type(proposed_function->id->value,translation_data);
- if(proposed_function_type->specifier!=TS_FUNC)
+ proposed_function_pointer_type=(struct Type_Pointer*)extract_expresion_value_type(proposed_function->id->value,translation_data);
+ if(proposed_function_pointer_type->specifier!=TS_POINTER)
{
- push_translation_error("is not a function",translation_data);
+ push_translation_error("%T is not a pointer to function",translation_data,proposed_function_pointer_type);
+ return 0;
+ }
+ proposed_function_type=(struct Type_Function*)proposed_function_pointer_type->points_to;
+ if(proposed_function_pointer_type->specifier!=TS_POINTER)
+ {
+ push_translation_error("%T is not a function type",translation_data,proposed_function_type);
return 0;
}
F diff --git a/src/semantics/value/constant.c b/src/semantics/value/constant.c
--- a/src/semantics/value/constant.c
+++ b/src/semantics/value/constant.c
*ret_component=.0l;
ret->value=ret_component;
- ret->type=(struct Type*)get_type_insecure(TS_INT,TSIGN_NONE,TC_NONE,INT_SIZE,translation_data);
+ ret->type=(struct Type*)get_type_insecure(TS_DOUBLE,TSIGN_NONE,TC_NONE,DOUBLE_SIZE,translation_data);
return ret;
}
F diff --git a/src/semantics/value/type.c b/src/semantics/value/type.c
--- a/src/semantics/value/type.c
+++ b/src/semantics/value/type.c
{
return (type->specifier==TS_POINTER && type_is_basic(AS_TYPE_PTR_PTR(type)->points_to) && AS_BASIC_TYPE_PTR(AS_TYPE_PTR_PTR(type)->points_to)->specifier==TS_VOID);
}
+ _Bool type_is_pointer_to_function(struct Type *type)
+ {
+ return (type->specifier==TS_POINTER && AS_TYPE_PTR_PTR(type)->points_to->specifier==TS_FUNC);
+ }
_Bool type_is_real(struct Type *type)
{
F diff --git a/src/semantics/value/type.h b/src/semantics/value/type.h
--- a/src/semantics/value/type.h
+++ b/src/semantics/value/type.h
_Bool type_is_pointer_to_object(struct Type *type);
_Bool type_is_pointer_to_incomplete_type(struct Type *type);
_Bool type_is_pointer_to_void(struct Type *type);
+ _Bool type_is_pointer_to_function(struct Type *type);
_Bool type_is_real(struct Type *type);
_Bool type_is_floating(struct Type *type);
_Bool type_is_derivative(struct Type *type);
F diff --git a/tests/test_typedef.c b/tests/test_typedef.c
--- a/tests/test_typedef.c
+++ b/tests/test_typedef.c
{
rfunc func;
func=d_id;
- func(0);
+ func(0.0);
return 0;
}