]> granicus.if.org Git - clang/commitdiff
Check for ivar being a C++ object before attempting to
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 15 Oct 2010 22:42:59 +0000 (22:42 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 15 Oct 2010 22:42:59 +0000 (22:42 +0000)
find a copy constructor/assignment operator used
in getter/setter synthesis. This removes an unintended
diagnostics and makes objc++ consistant with objective-c.
// rdar: //8550657.

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

lib/Sema/SemaObjCProperty.cpp
test/SemaObjCXX/property-synthesis-error.mm

index f7555cfa6a0ec2cef15255c3e8d165162161549f..251af224153fa31cda7e48258846fdd103c1ca70 100644 (file)
@@ -460,7 +460,8 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
                                Ivar);
   if (ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
     getterMethod->createImplicitParams(Context, IDecl);
-    if (getLangOptions().CPlusPlus && Synthesize) {
+    if (getLangOptions().CPlusPlus && Synthesize &&
+        Ivar->getType()->isRecordType()) {
       // For Objective-C++, need to synthesize the AST for the IVAR object to be
       // returned by the getter as it must conform to C++'s copy-return rules.
       // FIXME. Eventually we want to do this for Objective-C as well.
@@ -488,7 +489,8 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
   }
   if (ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
     setterMethod->createImplicitParams(Context, IDecl);
-    if (getLangOptions().CPlusPlus && Synthesize) {
+    if (getLangOptions().CPlusPlus && Synthesize
+        && Ivar->getType()->isRecordType()) {
       // FIXME. Eventually we want to do this for Objective-C as well.
       ImplicitParamDecl *SelfDecl = setterMethod->getSelfDecl();
       DeclRefExpr *SelfExpr = 
index 59e17b2a8d435afe0681fe9093eae407dc16b302..c7a279cfd7a04d8fbb8f2ba7e935605d79782625 100644 (file)
@@ -22,7 +22,7 @@
 
 @implementation MyClass
 
-@synthesize array=_array; // expected-error {{assigning to 'NSMutableArray *' from incompatible type 'NSArray *'}}
+@synthesize array=_array;
 
 @end