Check that the return/argument types of calls are complete.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67485 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 5539df4..079ff74 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2161,6 +2161,12 @@
if (i < NumArgs) {
Arg = Args[i];
+ if (RequireCompleteType(Arg->getSourceRange().getBegin(),
+ ProtoArgType,
+ diag::err_call_incomplete_argument,
+ Arg->getSourceRange()))
+ return true;
+
// Pass the argument.
if (PerformCopyInitialization(Arg, ProtoArgType, "passing"))
return true;
@@ -2331,6 +2337,14 @@
return ExprError(Diag(LParenLoc, diag::err_typecheck_call_not_function)
<< Fn->getType() << Fn->getSourceRange());
+ // Check for a valid return type
+ if (!FuncT->getResultType()->isVoidType() &&
+ RequireCompleteType(Fn->getSourceRange().getBegin(),
+ FuncT->getResultType(),
+ diag::err_call_incomplete_return,
+ TheCall->getSourceRange()))
+ return ExprError();
+
// We know the result type of the call, set it.
TheCall->setType(FuncT->getResultType().getNonReferenceType());
@@ -2345,6 +2359,11 @@
for (unsigned i = 0; i != NumArgs; i++) {
Expr *Arg = Args[i];
DefaultArgumentPromotion(Arg);
+ if (RequireCompleteType(Arg->getSourceRange().getBegin(),
+ Arg->getType(),
+ diag::err_call_incomplete_argument,
+ Arg->getSourceRange()))
+ return ExprError();
TheCall->setArg(i, Arg);
}
}