From: Eli Friedman Date: Fri, 2 Sep 2011 17:38:59 +0000 (+0000) Subject: Make StmtDumper::VisitCXXFunctionalCastExpr dump the attached cast kind. Fix the... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc2fca2ba2716293204901b8d2393428b965f12a;p=clang Make StmtDumper::VisitCXXFunctionalCastExpr dump the attached cast kind. Fix the cast kind for a cast from floating-point to enum type. (The difference isn't actually visible, but that's just because IRGen is overly forgiving.) Per report by Enea Zaffanella on cfe-dev. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139011 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp index ce4ae8e773..473837b330 100644 --- a/lib/AST/StmtDumper.cpp +++ b/lib/AST/StmtDumper.cpp @@ -557,7 +557,8 @@ void StmtDumper::VisitCXXThisExpr(CXXThisExpr *Node) { void StmtDumper::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) { DumpExpr(Node); - OS << " functional cast to " << Node->getTypeAsWritten().getAsString(); + OS << " functional cast to " << Node->getTypeAsWritten().getAsString() + << " <" << Node->getCastKindName() << ">"; } void StmtDumper::VisitCXXConstructExpr(CXXConstructExpr *Node) { diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index 2c6b8e748b..708433f62c 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -815,11 +815,12 @@ static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, // The same goes for reverse floating point promotion/conversion and // floating-integral conversions. Again, only floating->enum is relevant. if (DestType->isEnumeralType()) { - if (SrcType->isComplexType() || SrcType->isVectorType()) { - // Fall through - these cannot be converted. - } else if (SrcType->isArithmeticType() || SrcType->isEnumeralType()) { + if (SrcType->isIntegralOrEnumerationType()) { Kind = CK_IntegralCast; return TC_Success; + } else if (SrcType->isRealFloatingType()) { + Kind = CK_FloatingToIntegral; + return TC_Success; } }