]> granicus.if.org Git - clang/commitdiff
Categories cannot synthesize property ivars,
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 19 Jul 2010 16:14:33 +0000 (16:14 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 19 Jul 2010 16:14:33 +0000 (16:14 +0000)
and a minor cleanup.

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

lib/Sema/SemaExpr.cpp
test/SemaObjC/synth-provisional-ivars.m

index 2d3aaf6edc05daf74742b8bdc70061ec94b270b0..447dc387320cabf179bd9215e75895fe6dc9833b 100644 (file)
@@ -1006,7 +1006,6 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
 }
 
 static ObjCIvarDecl *SynthesizeProvisionalIvar(Sema &SemaRef,
-                                               ASTContext &Context,
                                                IdentifierInfo *II,
                                                SourceLocation NameLoc) {
   ObjCMethodDecl *CurMeth = SemaRef.getCurMethodDecl();
@@ -1014,7 +1013,8 @@ static ObjCIvarDecl *SynthesizeProvisionalIvar(Sema &SemaRef,
   if (!IDecl)
     return 0;
   ObjCImplementationDecl *ClassImpDecl = IDecl->getImplementation();
-  assert(ClassImpDecl && "Method not inside @implementation");
+  if (!ClassImpDecl)
+    return 0;
   bool DynamicImplSeen = false;
   ObjCPropertyDecl *property = SemaRef.LookupPropertyDecl(IDecl, II);
   if (!property)
@@ -1023,8 +1023,8 @@ static ObjCIvarDecl *SynthesizeProvisionalIvar(Sema &SemaRef,
     DynamicImplSeen = 
       (PIDecl->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic);
   if (!DynamicImplSeen) {
-    QualType PropType = Context.getCanonicalType(property->getType());
-    ObjCIvarDecl *Ivar = ObjCIvarDecl::Create(Context, ClassImpDecl, 
+    QualType PropType = SemaRef.Context.getCanonicalType(property->getType());
+    ObjCIvarDecl *Ivar = ObjCIvarDecl::Create(SemaRef.Context, ClassImpDecl, 
                                               NameLoc,
                                               II, PropType, /*Dinfo=*/0,
                                               ObjCIvarDecl::Protected,
@@ -1104,7 +1104,7 @@ Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S,
       if (Ex) return Owned(Ex);
       // Synthesize ivars lazily
       if (getLangOptions().ObjCNonFragileABI2) {
-        if (SynthesizeProvisionalIvar(*this, Context, II, NameLoc))
+        if (SynthesizeProvisionalIvar(*this, II, NameLoc))
           return ActOnIdExpression(S, SS, Id, HasTrailingLParen,
                                    isAddressOfOperand);
       }
index 2a1a6b15fa5418c2aa7b1294468a65ab529710b2..6ed424dae87e08a2d71a75509dd36d98fb7316c8 100644 (file)
@@ -38,3 +38,8 @@ int bar;
 - (int) Meth6 { return bar1; }
 
 @end
+
+@implementation I(CAT)
+- (int) Meth { return PROP1; }  // expected-error {{use of undeclared identifier 'PROP1'}}
+@end
+