[cfe-commits] r127257 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaExprObjC.cpp test/SemaObjC/class-unavail-warning.m

Fariborz Jahanian fjahanian at apple.com
Tue Mar 8 11:12:47 PST 2011


Author: fjahanian
Date: Tue Mar  8 13:12:46 2011
New Revision: 127257

URL: http://llvm.org/viewvc/llvm-project?rev=127257&view=rev
Log:
Warn on usage of unavailable objc 'class' in
varienty of cases. // rdar://9092208

Added:
    cfe/trunk/test/SemaObjC/class-unavail-warning.m
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=127257&r1=127256&r2=127257&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Mar  8 13:12:46 2011
@@ -212,6 +212,7 @@
       }
     }
   } else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) {
+    (void)DiagnoseUseOfDecl(IDecl, NameLoc);
     if (!HasTrailingDot)
       T = Context.getObjCInterfaceType(IDecl);
   }

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=127257&r1=127256&r2=127257&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Mar  8 13:12:46 2011
@@ -868,7 +868,7 @@
     return ExprError();
   }
   assert(Class && "We don't know which class we're messaging?");
-
+  (void)DiagnoseUseOfDecl(Class, Loc);
   // Find the method we are messaging.
   if (!Method) {
     if (Class->isForwardDecl()) {

Added: cfe/trunk/test/SemaObjC/class-unavail-warning.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-unavail-warning.m?rev=127257&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/class-unavail-warning.m (added)
+++ cfe/trunk/test/SemaObjC/class-unavail-warning.m Tue Mar  8 13:12:46 2011
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+// rdar://9092208
+
+__attribute__((unavailable("not available")))
+ at interface MyClass { // expected-note 5 {{function has been explicitly marked unavailable here}}
+ at public
+    void *_test;
+}
+
+- (id)self;
+- new;
++ (void)addObject:(id)anObject;
+
+ at end
+
+int main() {
+ [MyClass new]; // expected-error {{'MyClass' is unavailable: not available}}
+ [MyClass self]; // expected-error {{'MyClass' is unavailable: not available}}
+ [MyClass addObject:((void *)0)]; // expected-error {{'MyClass' is unavailable: not available}}
+
+ MyClass *foo = [MyClass new]; // expected-error 2 {{'MyClass' is unavailable: not available}}
+
+ return 0;
+}





More information about the cfe-commits mailing list