File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -460,10 +460,32 @@ void TypeChecker::Visitor::operator()(CallExpressionAST* ast) {
460460 }
461461
462462 auto functionType = type_cast<FunctionType>(ast->baseExpression ->type );
463+
464+ if (!functionType) {
465+ if (control ()->is_pointer (ast->baseExpression ->type )) {
466+ // ressolve pointer to function type
467+ functionType = type_cast<FunctionType>(
468+ control ()->get_element_type (ast->baseExpression ->type ));
469+ }
470+
471+ if (functionType && is_parsing_c ()) {
472+ (void )ensure_prvalue (ast->baseExpression );
473+ }
474+ }
475+
463476 if (!functionType) {
477+ // todo: enable when support for the __builtin_<op> functions is added
478+
479+ #if false
480+ error (ast->firstSourceLocation (),
481+ std::format (" invalid call of type '{}'" ,
482+ to_string (ast->baseExpression ->type )));
483+ #endif
464484 return ;
465485 }
466486
487+ // TODO: check the arguments
488+
467489 ast->type = functionType->returnType ();
468490
469491 if (control ()->is_lvalue_reference (ast->type )) {
Original file line number Diff line number Diff line change 1+ // RUN: %cxx -verify -fcheck %s
2+
3+ int f () { return 0 ; }
4+
5+ int main () {
6+ int (* fptr )() = f ;
7+ (void )_Generic(fptr (), int : 1 );
8+ }
You can’t perform that action at this time.
0 commit comments