From: Eli Friedman Date: Tue, 9 Jul 2013 01:38:07 +0000 (+0000) Subject: Fix recovery for missing * in objc property. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27d4644f4fad002b9e1be87c4e07f0f0c8240e1d;p=clang Fix recovery for missing * in objc property. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185897 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index ff5f7a5892..803bd7de88 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -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(CDecl); ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC, diff --git a/test/SemaObjCXX/properties.mm b/test/SemaObjCXX/properties.mm index abd4db998b..36f59b650c 100644 --- a/test/SemaObjCXX/properties.mm +++ b/test/SemaObjCXX/properties.mm @@ -164,3 +164,11 @@ namespace test10 { (void) t.index[t.b]; } } + +// +@interface PropertyOfItself +@property (readonly, nonatomic) PropertyOfItself x; // expected-error {{interface type cannot be statically allocated}} +@end +@implementation PropertyOfItself +@synthesize x; +@end