diff options
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 2f86fe1ffe..9d1b0849ef 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -437,6 +437,13 @@ static void HandleMallocAttr(Decl *d, const AttributeList &Attr, Sema &S) { return; } + if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) { + if (!FD->getResultType()->isPointerType()) { + S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only); + return; + } + } + d->addAttr(::new (S.Context) MallocAttr()); } |