]> granicus.if.org Git - clang/commitdiff
de-sugared when accessing property reference type.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 30 Mar 2011 16:59:30 +0000 (16:59 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 30 Mar 2011 16:59:30 +0000 (16:59 +0000)
Add a test case for synthesize ivar. // rdar://9070460

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

lib/Sema/SemaExpr.cpp
lib/Sema/SemaObjCProperty.cpp
test/SemaObjCXX/property-reference.mm [new file with mode: 0644]

index 22b0f03a52d69586140046154f37d4a396cb2dad..9ebc7de84d333344697c89d605879616292811f4 100644 (file)
@@ -7421,7 +7421,7 @@ static bool IsConstProperty(Expr *E, Sema &S) {
     ObjCPropertyDecl *PDecl = PropExpr->getExplicitProperty();
     QualType T = PDecl->getType();
     if (T->isReferenceType())
-      T = cast<ReferenceType>(T)->getPointeeType();
+      T = T->getAs<ReferenceType>()->getPointeeType();
     CanQualType CT = S.Context.getCanonicalType(T);
     return CT.isConstQualified();
   }
index 43e30275e2ff4bb03c263af35a91a4e7c728269a..95a365cacf651cb2e5d850fd0c329cf0712d72b1 100644 (file)
@@ -540,7 +540,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
       ParmVarDecl *Param = (*P);
       QualType T = Param->getType();
       if (T->isReferenceType())
-        T = cast<ReferenceType>(T)->getPointeeType();
+        T = T->getAs<ReferenceType>()->getPointeeType();
       Expr *rhs = new (Context) DeclRefExpr(Param, T,
                                             VK_LValue, SourceLocation());
       ExprResult Res = BuildBinOp(S, lhs->getLocEnd(), 
diff --git a/test/SemaObjCXX/property-reference.mm b/test/SemaObjCXX/property-reference.mm
new file mode 100644 (file)
index 0000000..5dc8061
--- /dev/null
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -fobjc-nonfragile-abi %s
+// rdar://9070460
+
+class TCPPObject
+{
+public:
+       TCPPObject(const TCPPObject& inObj);
+       TCPPObject();
+       ~TCPPObject();
+       
+       TCPPObject& operator=(const TCPPObject& inObj)const ;
+
+       void* Data();
+       
+private:
+       void* fData;
+};
+
+
+typedef const TCPPObject& CREF_TCPPObject;
+
+@interface TNSObject
+@property (assign, readwrite, nonatomic) CREF_TCPPObject cppObjectNonAtomic;
+@property (assign, readwrite) CREF_TCPPObject cppObjectAtomic;
+@property (assign, readwrite, nonatomic) const TCPPObject& cppObjectDynamic;
+@end
+
+
+@implementation TNSObject
+
+@synthesize cppObjectNonAtomic;
+@synthesize cppObjectAtomic;
+@dynamic cppObjectDynamic;
+
+- (const TCPPObject&) cppObjectNonAtomic
+{
+       return cppObjectNonAtomic;
+}
+
+- (void) setCppObjectNonAtomic: (const TCPPObject&)cppObject
+{
+       cppObjectNonAtomic = cppObject;
+}
+@end