aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-05-07 23:06:50 +0000
committerMike Stump <mrs@apple.com>2009-05-07 23:06:50 +0000
commit046efd92714dce712ad47bedfbdbb64e6eb35eec (patch)
tree898d4e229793550e87560411554bedf5b93f4415
parent913af35741b55fe854bc26c9dddc312cd991e24d (diff)
Add a warning for a missing copy attribute on a property that is a
block pointer. Radar 6441502 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71190 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--lib/Sema/SemaDeclObjC.cpp5
-rw-r--r--test/SemaObjC/block-attr.m9
3 files changed, 17 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 7ac13d83fc..3b8f24bc65 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -194,6 +194,9 @@ def warn_objc_property_default_assign_on_object : Warning<
"default property attribute 'assign' not appropriate for non-gc object">;
def warn_property_attr_mismatch : Warning<
"property attribute in continuation class does not match the primary class">;
+def warn_objc_property_copy_missing_on_block : Warning<
+ "'copy' attribute must be specified for the block property "
+ "when -fobjc-gc-only is specified">;
def err_use_continuation_class : Error<
"attribute of property in continuation class of %0 can only be 'readwrite'">;
def err_continuation_class : Error<"continuation class has no primary class">;
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 27f127716e..e35b7a919b 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1750,6 +1750,11 @@ void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
// <rdar://5168496&4855821&5607453&5096644&4947311&5698469&4947014&5168496>
// (please trim this list while you are at it).
}
+
+ if (!(Attributes & ObjCDeclSpec::DQ_PR_copy)
+ && getLangOptions().getGCMode() == LangOptions::GCOnly
+ && PropertyTy->isBlockPointerType())
+ Diag(Loc, diag::warn_objc_property_copy_missing_on_block);
}
Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
diff --git a/test/SemaObjC/block-attr.m b/test/SemaObjC/block-attr.m
new file mode 100644
index 0000000000..d67fd35435
--- /dev/null
+++ b/test/SemaObjC/block-attr.m
@@ -0,0 +1,9 @@
+// RUN: clang-cc -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -fobjc-gc-only %s
+
+@interface Thing {}
+
+@property void(^someBlock)(void); // expected-warning {{'copy' attribute must be specified for the block property}}
+@property(copy) void(^OK)(void);
+
+
+@end