From 61750f2bed7f5c0e440318841e3be385920b22f3 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 30 Mar 2011 16:59:30 +0000 Subject: [PATCH] de-sugared when accessing property reference type. 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 | 2 +- lib/Sema/SemaObjCProperty.cpp | 2 +- test/SemaObjCXX/property-reference.mm | 44 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 test/SemaObjCXX/property-reference.mm diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 22b0f03a52..9ebc7de84d 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -7421,7 +7421,7 @@ static bool IsConstProperty(Expr *E, Sema &S) { ObjCPropertyDecl *PDecl = PropExpr->getExplicitProperty(); QualType T = PDecl->getType(); if (T->isReferenceType()) - T = cast(T)->getPointeeType(); + T = T->getAs()->getPointeeType(); CanQualType CT = S.Context.getCanonicalType(T); return CT.isConstQualified(); } diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 43e30275e2..95a365cacf 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -540,7 +540,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, ParmVarDecl *Param = (*P); QualType T = Param->getType(); if (T->isReferenceType()) - T = cast(T)->getPointeeType(); + T = T->getAs()->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 index 0000000000..5dc8061de7 --- /dev/null +++ b/test/SemaObjCXX/property-reference.mm @@ -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 -- 2.40.0