]> granicus.if.org Git - clang/commitdiff
Objective-C. Don't ignore availability attribute when
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 10 Jun 2014 19:02:48 +0000 (19:02 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 10 Jun 2014 19:02:48 +0000 (19:02 +0000)
doing Objective-C subscript access. // rdar://16842487
PR19682.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210565 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaPseudoObject.cpp
test/SemaObjC/objc-container-subscripting-attr.m [new file with mode: 0644]

index eaed1e47e98c9f994926d5ba3746202f0ca4654c..c649cbe38d1f947c90cce8fda71620285274494c 100644 (file)
@@ -1359,6 +1359,8 @@ ExprResult ObjCSubscriptOpBuilder::buildGet() {
   // Arguments.
   Expr *args[] = { Index };
   assert(InstanceBase);
+  if (AtIndexGetter)
+    S.DiagnoseUseOfDecl(AtIndexGetter, GenericLoc);
   msg = S.BuildInstanceMessageImplicit(InstanceBase, receiverType,
                                        GenericLoc,
                                        AtIndexGetterSelector, AtIndexGetter,
@@ -1375,7 +1377,8 @@ ExprResult ObjCSubscriptOpBuilder::buildSet(Expr *op, SourceLocation opcLoc,
                                            bool captureSetValueAsResult) {
   if (!findAtIndexSetter())
     return ExprError();
-  
+  if (AtIndexSetter)
+    S.DiagnoseUseOfDecl(AtIndexSetter, GenericLoc);
   QualType receiverType = InstanceBase->getType();
   Expr *Index = InstanceKey;
   
diff --git a/test/SemaObjC/objc-container-subscripting-attr.m b/test/SemaObjC/objc-container-subscripting-attr.m
new file mode 100644 (file)
index 0000000..17110c4
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://16842487
+// pr19682
+
+@interface Subscriptable
+- (id)objectForKeyedSubscript:(id)sub __attribute__((unavailable)); // expected-note 2 {{'objectForKeyedSubscript:' has been explicitly marked unavailable here}}
+- (void)setObject:(id)object forKeyedSubscript:(id)key __attribute__((unavailable)); // expected-note {{'setObject:forKeyedSubscript:' has been explicitly marked unavailable here}}
+@end
+
+id test(Subscriptable *obj) {
+  obj[obj] = obj;  // expected-error {{'setObject:forKeyedSubscript:' is unavailable}}
+  return obj[obj]; // expected-error {{'objectForKeyedSubscript:' is unavailable}}
+}
+
+id control(Subscriptable *obj) {
+  return [obj objectForKeyedSubscript:obj]; // expected-error {{'objectForKeyedSubscript:' is unavailable}}
+}
+