r185897 - Fix recovery for missing * in objc property.

Eli Friedman eli.friedman at gmail.com
Mon Jul 8 18:38:07 PDT 2013


Author: efriedma
Date: Mon Jul  8 20:38:07 2013
New Revision: 185897

URL: http://llvm.org/viewvc/llvm-project?rev=185897&view=rev
Log:
Fix recovery for missing * in objc property.

<rdar://problem/14354144>

Modified:
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp
    cfe/trunk/test/SemaObjCXX/properties.mm

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=185897&r1=185896&r2=185897&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Mon Jul  8 20:38:07 2013
@@ -529,8 +529,16 @@ ObjCPropertyDecl *Sema::CreatePropertyDe
           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,

Modified: cfe/trunk/test/SemaObjCXX/properties.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/properties.mm?rev=185897&r1=185896&r2=185897&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/properties.mm (original)
+++ cfe/trunk/test/SemaObjCXX/properties.mm Mon Jul  8 20:38:07 2013
@@ -164,3 +164,11 @@ namespace test10 {
     (void) t.index[t.b];
   }
 }
+
+// <rdar://problem/14354144>
+ at interface PropertyOfItself
+ at property (readonly, nonatomic) PropertyOfItself x; // expected-error {{interface type cannot be statically allocated}}
+ at end
+ at implementation PropertyOfItself
+ at synthesize x;
+ at end





More information about the cfe-commits mailing list