casting to void is ok for structs (C99 6.5.4p2), this fixes
one bogus error on PR1750.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43436 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 40205d3..88a72eb 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -693,14 +693,15 @@
 
   // C99 6.5.4p2: the cast type needs to be void or scalar and the expression
   // type needs to be scalar.
-  if (!castType->isScalarType() && !castType->isVoidType()) { 
-    return Diag(LParenLoc, diag::err_typecheck_cond_expect_scalar, 
-                castType.getAsString(), SourceRange(LParenLoc, RParenLoc));
-  }
-  if (!castExpr->getType()->isScalarType()) {
-    return Diag(castExpr->getLocStart(), 
-                diag::err_typecheck_expect_scalar_operand, 
-                castExpr->getType().getAsString(), castExpr->getSourceRange());
+  if (!castType->isVoidType()) {  // Cast to void allows any expr type.
+    if (!castType->isScalarType())
+      return Diag(LParenLoc, diag::err_typecheck_cond_expect_scalar, 
+                  castType.getAsString(), SourceRange(LParenLoc, RParenLoc));
+    if (!castExpr->getType()->isScalarType()) {
+      return Diag(castExpr->getLocStart(), 
+                  diag::err_typecheck_expect_scalar_operand, 
+                  castExpr->getType().getAsString(),castExpr->getSourceRange());
+    }
   }
   return new CastExpr(castType, castExpr, LParenLoc);
 }