From: Anders Carlsson Date: Fri, 16 Oct 2009 02:35:04 +0000 (+0000) Subject: Add a ToVoid cast kind and start using it. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebeaf2031c968143c531bfe232d7507f20c57347;p=clang Add a ToVoid cast kind and start using it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84241 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index d5dff5065d..67f493c47c 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1399,7 +1399,10 @@ public: CK_IntegralToPointer, /// CK_PointerToIntegral - Pointer to integral - CK_PointerToIntegral + CK_PointerToIntegral, + + /// CK_ToVoid - Cast to void. + CK_ToVoid }; private: diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 0e4a29f916..fa999ffe35 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -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!"); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d818a5027e..279f50b9a7 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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())) {