]> granicus.if.org Git - clang/commitdiff
Fixes access rues for ivars declared in class
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 22 Mar 2010 19:04:14 +0000 (19:04 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 22 Mar 2010 19:04:14 +0000 (19:04 +0000)
implementations (radar 7547942).

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Parse/ParseObjc.cpp
lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/ivar-in-implementations.m

index 752be5df7a12622bc006f10fd9ea9e6e257c446f..f1b2d1133f283be70004075a31f91e4dbb2986e7 100644 (file)
@@ -268,8 +268,6 @@ def err_duplicate_ivar_declaration : Error<
   "instance variable is already declared">;
 def warn_on_superclass_use : Warning<
   "class implementation may not have super class">;
-def err_non_private_ivar_declaration : Error<
-  "only private ivars may be declared in implementation">;
 def err_conflicting_ivar_bitwidth : Error<
   "instance variable %0 has conflicting bit-field width">;
 def err_conflicting_ivar_name : Error<
index 7b2b6e855bb73fec49931f812c4d4c1c4ba9c54d..7a8aed7a21fa828b24d960891cd351881ed8524d 100644 (file)
@@ -1236,7 +1236,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtImplementationDeclaration(
 
   if (Tok.is(tok::l_brace)) // we have ivars
     ParseObjCClassInstanceVariables(ImplClsType/*FIXME*/, 
-                                    tok::objc_protected, atLoc);
+                                    tok::objc_private, atLoc);
   ObjCImpDecl = ImplClsType;
   PendingObjCImpDecl.push_back(ObjCImpDecl);
   
index b2f671760ebefc74e658e3d4cade2e926a055eb0..1feeffdfe50aee19910a3f5ede0a6f6721ee9643 100644 (file)
@@ -667,8 +667,6 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
         Diag(ClsIvar->getLocation(), diag::note_previous_definition);
         continue;
       }
-      if (ImplIvar->getAccessControl() != ObjCIvarDecl::Private)
-        Diag(ImplIvar->getLocation(), diag::err_non_private_ivar_declaration); 
       // Instance ivar to Implementation's DeclContext.
       ImplIvar->setLexicalDeclContext(ImpDecl);
       IDecl->makeDeclVisibleInContext(ImplIvar, false);
index 32d3c353d04f332107aec1c7236297e0b9808ac5..4060526b44d5a022b27ad1fc761174ca8f25c61e 100644 (file)
 
 @implementation INTFSTANDALONE : Super // expected-warning {{class implementation may not have super class}}
 {
-@private
-  id IVAR1;
+  id PRIV_IVAR;
 @protected
-  id IVAR2;    // expected-error {{only private ivars may be declared in implementation}}
+  id PRTCTD;   
 @private
   id IVAR3;
   int IVAR;    // expected-error {{instance variable is already declared}}
+@public
+  id IVAR4;
 }
 @end
+
+@interface Base @end
+
+@implementation Base { 
+    int ivar1; 
+@public
+    int ivar2; 
+} 
+@end
+
+id fn1(INTFSTANDALONE *b) { return b->PRIV_IVAR; } // expected-error {{instance variable 'PRIV_IVAR' is private}}
+
+id fn2(INTFSTANDALONE *b) { return b->PRTCTD; }  // expected-error {{instance variable 'PRTCTD' is protected}}
+
+id fn4(INTFSTANDALONE *b) { return b->IVAR4; }
+