aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2013-04-24 06:52:20 +0000
committerTed Kremenek <kremenek@apple.com>2013-04-24 06:52:20 +0000
commit4abc9bd20590291f31f3507e36ffd4489f43021a (patch)
tree47fdb93b6d1be4b4f0fed4cfca89d8111ea1f4ab
parent3b6f56a51e50ec11cbd1f7e3aa4785fffa4e839d (diff)
Add test case for -Wdeprecated-objc-pointer-introspection, and
tweak warning to suggest that it is just a bad thing to do. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180175 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--test/SemaObjC/deprecated-objc-introspection.m8
2 files changed, 9 insertions, 1 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 0f73c7b416..6ba65c0a23 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -644,7 +644,7 @@ def warn_objc_isa_assign : Warning<
"object_setClass()">, InGroup<DeprecatedObjCIsaUsage>;
def warn_objc_pointer_masking : Warning<
"bitmasking for introspection of Objective-C object pointers is strongly "
- "discouraged in favor of using runtime APIs">,
+ "discouraged">,
InGroup<DiagGroup<"deprecated-objc-pointer-introspection">>;
def warn_objc_property_default_assign_on_object : Warning<
"default property attribute 'assign' not appropriate for non-GC object">,
diff --git a/test/SemaObjC/deprecated-objc-introspection.m b/test/SemaObjC/deprecated-objc-introspection.m
index 6d67641a81..faaef254d5 100644
--- a/test/SemaObjC/deprecated-objc-introspection.m
+++ b/test/SemaObjC/deprecated-objc-introspection.m
@@ -87,3 +87,11 @@ static void func() {
}
@end
+// Test for introspection of Objective-C pointers via bitmasking.
+
+void testBitmasking(NSObject *p) {
+ (void) (((NSUInteger) p) & 0x1); // expected-warning {{bitmasking for introspection of Objective-C object pointers is strongly discouraged}}
+ (void) (0x1 & ((NSUInteger) p)); // expected-warning {{bitmasking for introspection of Objective-C object pointers is strongly discouraged}}
+ (void) (((NSUInteger) p) ^ 0x1); // no-warning
+ (void) (0x1 ^ ((NSUInteger) p)); // no-warning
+} \ No newline at end of file