]> granicus.if.org Git - clang/commitdiff
Add a ToVoid cast kind and start using it.
authorAnders Carlsson <andersca@mac.com>
Fri, 16 Oct 2009 02:35:04 +0000 (02:35 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 16 Oct 2009 02:35:04 +0000 (02:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84241 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/AST/Expr.cpp
lib/Sema/SemaExpr.cpp

index d5dff5065d49ef0199f38489d9e46dd086a9feca..67f493c47cc95d75623439b926e1116597552ae7 100644 (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:
index 0e4a29f916fa356b93aab372a6f2f6d3fe8f70cc..fa999ffe35d36e14b5e17c3da1ef3a923da06e88 100644 (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!");
index d818a5027e61a20296b07d8d90ccbe8144b886bb..279f50b9a71fdc937fde9a0d06c4d2fd2f0580a7 100644 (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())) {