diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-03-30 16:59:30 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-03-30 16:59:30 +0000 |
commit | 61750f2bed7f5c0e440318841e3be385920b22f3 (patch) | |
tree | abcb041179d3705935f7712700990f693a1ddbd2 | |
parent | 68af13f3ca39947e3f285f864fe3b76640fddf69 (diff) |
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
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 2 | ||||
-rw-r--r-- | test/SemaObjCXX/property-reference.mm | 44 |
3 files changed, 46 insertions, 2 deletions
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<ReferenceType>(T)->getPointeeType(); + T = T->getAs<ReferenceType>()->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<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 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 |