Issue error instead of crashing given attempted function call through non-function.

Fixes issue #163.
This commit is contained in:
Matt Pharr
2012-01-27 10:01:06 -08:00
parent 5893a9c49d
commit 37cdc18639

View File

@@ -2679,11 +2679,11 @@ FunctionCallExpr::TypeCheck() {
if (fptrType == NULL)
return NULL;
Assert(dynamic_cast<const PointerType *>(fptrType) != NULL);
const FunctionType *funcType =
dynamic_cast<const FunctionType *>(fptrType->GetBaseType());
if (funcType == NULL) {
Error(pos, "Must provide function name or function pointer for "
// Make sure we do in fact have a function to call
const FunctionType *funcType;
if (dynamic_cast<const PointerType *>(fptrType) == NULL ||
(funcType = dynamic_cast<const FunctionType *>(fptrType->GetBaseType())) == NULL) {
Error(func->pos, "Must provide function name or function pointer for "
"function call expression.");
return NULL;
}