aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-11-18 06:52:58 +0000
committerTed Kremenek <kremenek@apple.com>2008-11-18 06:52:58 +0000
commit46bbacac37141ed9d01d5b6473e8211554b02710 (patch)
tree9ebde217a56aa3fd8af8fee8206cd2e4ed96d4be
parentf812a45dd93634c9300ed5533bd26b56374714a1 (diff)
Attribute nonnull can be applied to block pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59499 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclAttr.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index e1afd6d924..2b52029f73 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -341,7 +341,8 @@ static void HandleNonNullAttr(Decl *d, const AttributeList &Attr, Sema &S) {
--x;
// Is the function argument a pointer type?
- if (!getFunctionOrMethodArgType(d, x)->isPointerType()) {
+ QualType T = getFunctionOrMethodArgType(d, x);
+ if (!T->isPointerType() && !T->isBlockPointerType()) {
// FIXME: Should also highlight argument in decl.
S.Diag(Attr.getLoc(), diag::err_nonnull_pointers_only,
"nonnull", Ex->getSourceRange());
@@ -354,9 +355,11 @@ static void HandleNonNullAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// If no arguments were specified to __attribute__((nonnull)) then all
// pointer arguments have a nonnull attribute.
if (NonNullArgs.empty()) {
- for (unsigned I = 0, E = getFunctionOrMethodNumArgs(d); I != E; ++I)
- if (getFunctionOrMethodArgType(d, I)->isPointerType())
+ for (unsigned I = 0, E = getFunctionOrMethodNumArgs(d); I != E; ++I) {
+ QualType T = getFunctionOrMethodArgType(d, I);
+ if (T->isPointerType() || T->isBlockPointerType())
NonNullArgs.push_back(I);
+ }
if (NonNullArgs.empty()) {
S.Diag(Attr.getLoc(), diag::warn_attribute_nonnull_no_pointers);