Don't allow calls to functions marked "unavailable". There's more work
to do in this area, since there are other places that reference
FunctionDecls.

Don't allow "overloadable" functions (in C) to be declared without a
prototype.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64897 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index c0b61bf..48f338e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2032,13 +2032,21 @@
 
   // Make the call expr early, before semantic checks.  This guarantees cleanup
   // of arguments and function on error.
-  // FIXME: Except that llvm::OwningPtr uses delete, when it really must be
-  // Destroy(), or nothing gets cleaned up.
   ExprOwningPtr<CallExpr> TheCall(this, new (Context) CallExpr(Context, Fn,
                                                                Args, NumArgs,
                                                                Context.BoolTy,
                                                                RParenLoc));
 
+  // Check for a call to a (FIXME: deleted) or unavailable function.
+  if (FDecl && FDecl->getAttr<UnavailableAttr>()) {
+    Diag(Fn->getSourceRange().getBegin(), diag::err_call_deleted_function)
+      << FDecl->getAttr<UnavailableAttr>() << FDecl->getDeclName()
+      << Fn->getSourceRange();
+    Diag(FDecl->getLocation(), diag::note_deleted_function_here)
+      << FDecl->getAttr<UnavailableAttr>();
+    return ExprError();
+  }
+
   const FunctionType *FuncT;
   if (!Fn->getType()->isBlockPointerType()) {
     // C99 6.5.2.2p1 - "The expression that denotes the called function shall