aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaDeclAttr.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 23fe4010fb..76b99bb33f 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -438,22 +438,15 @@ static void HandleMallocAttr(Decl *d, const AttributeList &Attr, Sema &S) {
return;
}
- 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 = FT->getResultType();
-
- if (!(RetTy->isAnyPointerType() || RetTy->isBlockPointerType())) {
- S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only);
- return;
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
+ QualType RetTy = FD->getResultType();
+ if (RetTy->isAnyPointerType() || RetTy->isBlockPointerType()) {
+ d->addAttr(::new (S.Context) MallocAttr());
+ return;
+ }
}
- d->addAttr(::new (S.Context) MallocAttr());
+ S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only);
}
static bool HandleCommonNoReturnAttr(Decl *d, const AttributeList &Attr,