Add a ToVoid cast kind and start using it.

llvm-svn: 84241
This commit is contained in:
Anders Carlsson
2009-10-16 02:35:04 +00:00
parent cb4e68c340
commit ef918ac840
3 changed files with 11 additions and 2 deletions

View File

@@ -1399,7 +1399,10 @@ public:
CK_IntegralToPointer,
/// CK_PointerToIntegral - Pointer to integral
CK_PointerToIntegral
CK_PointerToIntegral,
/// CK_ToVoid - Cast to void.
CK_ToVoid
};
private:

View File

@@ -426,6 +426,8 @@ const char *CastExpr::getCastKindName() const {
return "IntegralToPointer";
case CastExpr::CK_PointerToIntegral:
return "PointerToIntegral";
case CastExpr::CK_ToVoid:
return "ToVoid";
}
assert(0 && "Unhandled cast kind!");

View File

@@ -3157,7 +3157,11 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr,
// type needs to be scalar.
if (castType->isVoidType()) {
// Cast to void allows any expr type.
} else if (!castType->isScalarType() && !castType->isVectorType()) {
Kind = CastExpr::CK_ToVoid;
return false;
}
if (!castType->isScalarType() && !castType->isVectorType()) {
if (Context.getCanonicalType(castType).getUnqualifiedType() ==
Context.getCanonicalType(castExpr->getType().getUnqualifiedType()) &&
(castType->isStructureType() || castType->isUnionType())) {