diff --git a/clang/AST/Expr.cpp b/clang/AST/Expr.cpp index c7a2005bc8f3..f4da0f075162 100644 --- a/clang/AST/Expr.cpp +++ b/clang/AST/Expr.cpp @@ -995,7 +995,7 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const { // Strip off a cast to void*, if it exists. if (const CastExpr *CE = dyn_cast(this)) { // Check that it is a cast to void*. - if (const PointerType *PT = dyn_cast(CE->getType())) { + if (const PointerType *PT = CE->getType()->getAsPointerType()) { QualType Pointee = PT->getPointeeType(); if (Pointee.getQualifiers() == 0 && Pointee->isVoidType() && // to void* CE->getSubExpr()->getType()->isIntegerType()) // from int. diff --git a/clang/test/Sema/conditional-expr.c b/clang/test/Sema/conditional-expr.c index 813aaee9d0d1..a21914c6d5cc 100644 --- a/clang/test/Sema/conditional-expr.c +++ b/clang/test/Sema/conditional-expr.c @@ -31,5 +31,8 @@ void foo() { enum {xxx,yyy,zzz} e, *ee; short x; ee = ee ? &x : ee ? &i : &e; // expected-warning {{pointer type mismatch}} + + typedef void *asdf; + *(0 ? (asdf) 0 : &x) = 10; }