aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-10-28 20:06:07 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-10-28 20:06:07 +0000
commit6d09f01af70bbd58ddbccb0a22f5479782b31797 (patch)
treeeea971606bfa52b78a63bad460ec340f4d332094 /lib/Sema/SemaExprObjC.cpp
parent26bae20cc0f55755f51b65b3022a8b5ca7d3d081 (diff)
objective-c arc: type-casting of an objc pointer to
an rvalue retainable object type with life-time qualifier has no effect and wil be diagnosed as error. // rdar://10244607 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143219 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r--lib/Sema/SemaExprObjC.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index ceff1de3d4..edf8b72050 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -1934,7 +1934,24 @@ Sema::CheckObjCARCConversion(SourceRange castRange, QualType castType,
ARCConversionTypeClass exprACTC = classifyTypeForARCConversion(castExprType);
ARCConversionTypeClass castACTC = classifyTypeForARCConversion(effCastType);
- if (exprACTC == castACTC) return ACR_okay;
+ if (exprACTC == castACTC) {
+ // check for viablity and report error if casting an rvalue to a
+ // life-time qualifier.
+ if ((castACTC == ACTC_retainable) &&
+ isa<AttributedType>(castType) &&
+ (castType.getObjCLifetime() != Qualifiers::OCL_None) &&
+ (CCK == CCK_CStyleCast || CCK == CCK_OtherCast) &&
+ castType != castExprType) {
+ SourceLocation loc =
+ (castRange.isValid() ? castRange.getBegin()
+ : castExpr->getExprLoc());
+ Diag(loc, diag::err_arc_nolifetime_behavior)
+ << effCastType << castExprType
+ << castRange << castExpr->getSourceRange();
+ }
+ return ACR_okay;
+ }
+
if (isAnyCLike(exprACTC) && isAnyCLike(castACTC)) return ACR_okay;
// Allow all of these types to be cast to integer types (but not