summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaCast.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2012-08-19 10:33:04 +0000
committerdim <dim@FreeBSD.org>2012-08-19 10:33:04 +0000
commitcc73504950eb7b5dff2dded9bedd67bc36d64641 (patch)
tree5b9c2fa9d79942fbdce3d618e37e27c18263af9a /lib/Sema/SemaCast.cpp
parent554bcb69c2d785a011a30e7db87a36a87fe7db10 (diff)
downloadFreeBSD-src-cc73504950eb7b5dff2dded9bedd67bc36d64641.zip
FreeBSD-src-cc73504950eb7b5dff2dded9bedd67bc36d64641.tar.gz
Vendor import of clang trunk r162107:
http://llvm.org/svn/llvm-project/cfe/trunk@162107
Diffstat (limited to 'lib/Sema/SemaCast.cpp')
-rw-r--r--lib/Sema/SemaCast.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp
index 8199751..d8d51e7 100644
--- a/lib/Sema/SemaCast.cpp
+++ b/lib/Sema/SemaCast.cpp
@@ -1477,6 +1477,21 @@ void Sema::CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
Diag(Range.getBegin(), DiagID) << SrcType << DestType << Range;
}
+static void DiagnoseCastOfObjCSEL(Sema &Self, const ExprResult &SrcExpr,
+ QualType DestType) {
+ QualType SrcType = SrcExpr.get()->getType();
+ if (const PointerType *SrcPtrTy = SrcType->getAs<PointerType>())
+ if (SrcPtrTy->isObjCSelType()) {
+ QualType DT = DestType;
+ if (isa<PointerType>(DestType))
+ DT = DestType->getPointeeType();
+ if (!DT.getUnqualifiedType()->isVoidType())
+ Self.Diag(SrcExpr.get()->getExprLoc(),
+ diag::warn_cast_pointer_from_sel)
+ << SrcType << DestType << SrcExpr.get()->getSourceRange();
+ }
+}
+
static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr,
QualType DestType, bool CStyle,
const SourceRange &OpRange,
@@ -1721,7 +1736,9 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr,
if (CStyle && DestType->isObjCObjectPointerType()) {
return TC_Success;
}
-
+ if (CStyle)
+ DiagnoseCastOfObjCSEL(Self, SrcExpr, DestType);
+
// Not casting away constness, so the only remaining check is for compatible
// pointer categories.
@@ -2058,6 +2075,7 @@ void CastOperation::CheckCStyleCast() {
return;
}
}
+ DiagnoseCastOfObjCSEL(Self, SrcExpr, DestType);
Kind = Self.PrepareScalarCast(SrcExpr, DestType);
if (SrcExpr.isInvalid())
OpenPOWER on IntegriCloud