diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-10-28 20:06:07 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-10-28 20:06:07 +0000 |
commit | 2fa646d5962323257a148060253b23b71543176a (patch) | |
tree | e3b9952109ca186a1226a1b76c0f617faa3ba6e1 /clang/lib/Sema/SemaExprObjC.cpp | |
parent | 104b7e3f2c0909c149bf62fc9474ecceed4d7d57 (diff) | |
download | bcm5719-llvm-2fa646d5962323257a148060253b23b71543176a.tar.gz bcm5719-llvm-2fa646d5962323257a148060253b23b71543176a.zip |
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
llvm-svn: 143219
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index ceff1de3d49..edf8b720504 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/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 |