aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2013-07-09 01:38:07 +0000
committerEli Friedman <eli.friedman@gmail.com>2013-07-09 01:38:07 +0000
commit999af7bf6e933700ee7e06d047490e050d283cea (patch)
tree6f57b6e8083970af49ed7ce9fa1f59659a4c9fed
parent701a3523bad654ce274345452c48ca977662b031 (diff)
downloadllvm-999af7bf6e933700ee7e06d047490e050d283cea.zip
llvm-999af7bf6e933700ee7e06d047490e050d283cea.tar.gz
llvm-999af7bf6e933700ee7e06d047490e050d283cea.tar.bz2
Fix recovery for missing * in objc property.
<rdar://problem/14354144> llvm-svn: 185897
-rw-r--r--clang/lib/Sema/SemaObjCProperty.cpp12
-rw-r--r--clang/test/SemaObjCXX/properties.mm8
2 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index ff5f7a5..803bd7d 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/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<DeclContext>(CDecl);
ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC,
diff --git a/clang/test/SemaObjCXX/properties.mm b/clang/test/SemaObjCXX/properties.mm
index abd4db9..36f59b6 100644
--- a/clang/test/SemaObjCXX/properties.mm
+++ b/clang/test/SemaObjCXX/properties.mm
@@ -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