From bd27073f2ab0b558aaa87c303fdf0fc5d54e8aca Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 18 Jul 2007 16:00:06 +0000 Subject: [PATCH] Cast to void is valid, patch by Benoit Boissinot llvm-svn: 40003 --- clang/Sema/SemaExpr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp index 6439e48e9d58..044fb63bf081 100644 --- a/clang/Sema/SemaExpr.cpp +++ b/clang/Sema/SemaExpr.cpp @@ -478,8 +478,9 @@ ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty, Expr *castExpr = static_cast(Op); QualType castType = QualType::getFromOpaquePtr(Ty); - // C99 6.5.4p2: both the cast type and expression type need to be scalars. - if (!castType->isScalarType()) { + // 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)); }