diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-07-07 23:04:17 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-07-07 23:04:17 +0000 |
commit | 7a084ec568f8336ec6f10011d0118a6b19e253cb (patch) | |
tree | 1c49bba913aae0ad3cdb8d6187df00c335b06740 /lib/Sema/SemaCXXCast.cpp | |
parent | 7c9adf9113b1d1dfeca1d265a7c3bedb3671cfab (diff) |
objc++-arc: diagnose assignment/cast of a weak-unavailable
object to a __weak object/type. // rdar://9732636.
One item is yet todo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134655 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXCast.cpp')
-rw-r--r-- | lib/Sema/SemaCXXCast.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index d053d5a9e9..0721814c18 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -1717,7 +1717,8 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK, Kind = CK_Dependent; return Owned(CastExpr); } - + + QualType origCastExprType = CastExpr->getType(); if (VK == VK_RValue && !CastTy->isRecordType()) { ExprResult CastExprRes = DefaultFunctionArrayLvalueConversion(CastExpr); if (CastExprRes.isInvalid()) @@ -1773,8 +1774,15 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK, } } - if (getLangOptions().ObjCAutoRefCount && tcr == TC_Success) + if (getLangOptions().ObjCAutoRefCount && tcr == TC_Success) { CheckObjCARCConversion(R, CastTy, CastExpr, CCK); + if (!CheckObjCARCUnavailableWeakConversion(CastTy, + origCastExprType)) + Diag(CastExpr->getLocStart(), + diag::err_arc_cast_of_weak_unavailable) + << origCastExprType << CastTy + << CastExpr->getSourceRange(); + } if (tcr != TC_Success && msg != 0) { if (CastExpr->getType() == Context.OverloadTy) { |