Per Eli Friedman's feedback, handle attribute 'malloc' being applied to
declarations of function pointers.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79053 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index e65b3aa..23fe401 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -437,16 +437,16 @@
     S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
     return;
   }
-
-  const FunctionDecl *FD = dyn_cast<FunctionDecl>(d);
-
-  if (!FD) {
+  
+  const FunctionType *FT = getFunctionType(d, false);
+  
+  if (!FT) {
     S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
       << Attr.getName() << 0 /*function*/;
     return;
   }
 
-  QualType RetTy = FD->getResultType();
+  QualType RetTy = FT->getResultType();
   
   if (!(RetTy->isAnyPointerType() || RetTy->isBlockPointerType())) {
     S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only);