Generate IR for calling function pointers.
authorChristoph Mallon <christoph.mallon@gmx.de>
Sat, 17 Nov 2007 19:40:31 +0000 (19:40 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 17 Nov 2007 19:40:31 +0000 (19:40 +0000)
[r18459]

ast2firm.c

index 2ec9b96..f0be12e 100644 (file)
@@ -701,8 +701,15 @@ static ir_node *call_expression_to_firm(const call_expression_t *call)
        expression_t  *function = call->function;
        ir_node       *callee   = expression_to_firm(function);
 
-       assert(function->datatype->type == TYPE_FUNCTION);
-       function_type_t *function_type = (function_type_t*) function->datatype;
+       function_type_t *function_type;
+       if (function->datatype->type == TYPE_POINTER) {
+               pointer_type_t *const ptr_type = (pointer_type_t*)function->datatype;
+               assert(ptr_type->points_to->type == TYPE_FUNCTION);
+               function_type = (function_type_t*)ptr_type->points_to;
+       } else {
+               assert(function->datatype->type == TYPE_FUNCTION);
+               function_type = (function_type_t*)function->datatype;
+       }
 
        int              n_parameters = 0;
        call_argument_t *argument     = call->arguments;