forked from OSchip/llvm-project
On bogus code like this:
int *P2; P2(1, 2, 3); register short X; X(); emit: ds.c:10:3: error: called object is not a function or function pointer P2(1, 2, 3); ^~~~~~~~~~~ ds.c:13:3: error: called object is not a function or function pointer X(); ^~~ instead of aborting. llvm-svn: 39599
This commit is contained in:
parent
3343f81a25
commit
3d01e4eacb
|
@ -367,10 +367,22 @@ ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
|
|||
QualType qType = UsualUnaryConversions(funcExpr->getType());
|
||||
assert(!qType.isNull() && "no type for function call expression");
|
||||
|
||||
const PointerType *PT = dyn_cast<PointerType>(qType.getCanonicalType());
|
||||
// C99 6.5.2.2p1 - "The expression that denotes the called function shall have
|
||||
// type pointer to function".
|
||||
const PointerType *PT = dyn_cast<PointerType>(qType);
|
||||
if (PT == 0) PT = dyn_cast<PointerType>(qType.getCanonicalType());
|
||||
|
||||
if (PT == 0)
|
||||
return Diag(funcExpr->getLocStart(), diag::err_typecheck_call_not_function,
|
||||
SourceRange(funcExpr->getLocStart(), RParenLoc));
|
||||
|
||||
const FunctionType *funcT = dyn_cast<FunctionType>(PT->getPointeeType());
|
||||
assert(funcT && "ParseCallExpr(): not a function type");
|
||||
if (funcT == 0)
|
||||
funcT = dyn_cast<FunctionType>(PT->getPointeeType().getCanonicalType());
|
||||
|
||||
if (funcT == 0)
|
||||
return Diag(funcExpr->getLocStart(), diag::err_typecheck_call_not_function,
|
||||
SourceRange(funcExpr->getLocStart(), RParenLoc));
|
||||
|
||||
// If a prototype isn't declared, the parser implicitly defines a func decl
|
||||
QualType resultType = funcT->getResultType();
|
||||
|
|
|
@ -590,6 +590,8 @@ DIAG(err_typecheck_expression_not_modifiable_lvalue, ERROR,
|
|||
"expression is not assignable")
|
||||
DIAG(err_typecheck_incomplete_type_not_modifiable_lvalue, ERROR,
|
||||
"incomplete type '%0' is not assignable")
|
||||
DIAG(err_typecheck_call_not_function, ERROR,
|
||||
"called object is not a function or function pointer")
|
||||
DIAG(err_typecheck_call_too_few_args, ERROR,
|
||||
"too few arguments to function")
|
||||
DIAG(err_typecheck_call_too_many_args, ERROR,
|
||||
|
|
Loading…
Reference in New Issue