diff options
author | Ryan Flynn <pizza@parseerror.com> | 2009-08-09 22:36:29 +0000 |
---|---|---|
committer | Ryan Flynn <pizza@parseerror.com> | 2009-08-09 22:36:29 +0000 |
commit | e64ffc277c92af0e2b50751142641198ac74a131 (patch) | |
tree | c8fc779d73326cab41b897190e73fff92b9705f2 /clang/lib/Sema/SemaDeclAttr.cpp | |
parent | 1f1fdc070efa8d32d97a51dbffdae466ad83e480 (diff) | |
download | bcm5719-llvm-e64ffc277c92af0e2b50751142641198ac74a131.tar.gz bcm5719-llvm-e64ffc277c92af0e2b50751142641198ac74a131.zip |
warn, as gcc does, if __attribute__((malloc)) applied to function returning non-pointer type
llvm-svn: 78542
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 2f86fe1ffe7..9d1b0849eff 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/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()); } |