aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorRyan Flynn <pizza@parseerror.com>2009-08-09 22:36:29 +0000
committerRyan Flynn <pizza@parseerror.com>2009-08-09 22:36:29 +0000
commitfd6ad3cf9c8fc6904bd5f33212207aa69743fd45 (patch)
tree4c3454a4bcb8731ac5ca025d8fb51e998f03e2a5 /lib/Sema
parent76168e289ca4b307259e3bc9b3353f03b05bb6b9 (diff)
warn, as gcc does, if __attribute__((malloc)) applied to function returning non-pointer type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78542 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaDeclAttr.cpp7
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());
}