]> granicus.if.org Git - clang/commitdiff
Fix recovery for missing * in objc property.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 9 Jul 2013 01:38:07 +0000 (01:38 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 9 Jul 2013 01:38:07 +0000 (01:38 +0000)
<rdar://problem/14354144>

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

lib/Sema/SemaObjCProperty.cpp
test/SemaObjCXX/properties.mm

index ff5f7a58927920773572b198677fcee37f267450..803bd7de881fad50c5134b6ca7dd737ce3f0756c 100644 (file)
@@ -529,8 +529,16 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S,
           if (IDecl->ClassImplementsProtocol(PNSCopying, true))
             Diag(AtLoc, diag::warn_implements_nscopying) << PropertyId;
     }
-  if (T->isObjCObjectType())
-    Diag(FD.D.getIdentifierLoc(), diag::err_statically_allocated_object);
+
+  if (T->isObjCObjectType()) {
+    SourceLocation StarLoc = TInfo->getTypeLoc().getLocEnd();
+    StarLoc = PP.getLocForEndOfToken(StarLoc);
+    Diag(FD.D.getIdentifierLoc(), diag::err_statically_allocated_object)
+      << FixItHint::CreateInsertion(StarLoc, "*");
+    T = Context.getObjCObjectPointerType(T);
+    SourceLocation TLoc = TInfo->getTypeLoc().getLocStart();
+    TInfo = Context.getTrivialTypeSourceInfo(T, TLoc);
+  }
 
   DeclContext *DC = cast<DeclContext>(CDecl);
   ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC,
index abd4db998bcc50d7cb2d1bc2e55e8d4c4fa58d38..36f59b650cec7a0e84e4a3c5c4ace71984604883 100644 (file)
@@ -164,3 +164,11 @@ namespace test10 {
     (void) t.index[t.b];
   }
 }
+
+// <rdar://problem/14354144>
+@interface PropertyOfItself
+@property (readonly, nonatomic) PropertyOfItself x; // expected-error {{interface type cannot be statically allocated}}
+@end
+@implementation PropertyOfItself
+@synthesize x;
+@end