r210565 - Objective-C. Don't ignore availability attribute when

Fariborz Jahanian fjahanian at apple.com
Tue Jun 10 12:02:48 PDT 2014


Author: fjahanian
Date: Tue Jun 10 14:02:48 2014
New Revision: 210565

URL: http://llvm.org/viewvc/llvm-project?rev=210565&view=rev
Log:
Objective-C. Don't ignore availability attribute when
doing Objective-C subscript access. // rdar://16842487
PR19682.

Added:
    cfe/trunk/test/SemaObjC/objc-container-subscripting-attr.m
Modified:
    cfe/trunk/lib/Sema/SemaPseudoObject.cpp

Modified: cfe/trunk/lib/Sema/SemaPseudoObject.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaPseudoObject.cpp?rev=210565&r1=210564&r2=210565&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/trunk/lib/Sema/SemaPseudoObject.cpp Tue Jun 10 14:02:48 2014
@@ -1359,6 +1359,8 @@ ExprResult ObjCSubscriptOpBuilder::build
   // 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::build
                                            bool captureSetValueAsResult) {
   if (!findAtIndexSetter())
     return ExprError();
-  
+  if (AtIndexSetter)
+    S.DiagnoseUseOfDecl(AtIndexSetter, GenericLoc);
   QualType receiverType = InstanceBase->getType();
   Expr *Index = InstanceKey;
   

Added: cfe/trunk/test/SemaObjC/objc-container-subscripting-attr.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc-container-subscripting-attr.m?rev=210565&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/objc-container-subscripting-attr.m (added)
+++ cfe/trunk/test/SemaObjC/objc-container-subscripting-attr.m Tue Jun 10 14:02:48 2014
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://16842487
+// pr19682
+
+ at 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}}
+ at 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}}
+}
+





More information about the cfe-commits mailing list