From 58a2e944faa16f1f61439acd2e71b19f50189511 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 26 Aug 2007 07:26:12 +0000 Subject: [PATCH] there are no conversions from aggregates to scalars. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41440 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CGExprScalar.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/CodeGen/CGExprScalar.cpp b/CodeGen/CGExprScalar.cpp index ebe25c5a88..d9114beb11 100644 --- a/CodeGen/CGExprScalar.cpp +++ b/CodeGen/CGExprScalar.cpp @@ -365,30 +365,23 @@ Value *ScalarExprEmitter::VisitImplicitCastExpr(const ImplicitCastExpr *E) { // have to handle a more broad range of conversions than explicit casts, as they // handle things like function to ptr-to-function decay etc. Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy) { - // Handle cases where the source is an LLVM Scalar type. - if (!CGF.hasAggregateLLVMType(E->getType())) { + // Handle cases where the source is an non-complex type. + const ComplexType *CT = E->getType()->getAsComplexType(); + if (!CT) { Value *Src = Visit(const_cast(E)); // Use EmitScalarConversion to perform the conversion. return EmitScalarConversion(Src, E->getType(), DestTy); } - - if (const ComplexType *CT = E->getType()->getAsComplexType()) { - // Emit the complex value, only keeping the real component. C99 6.3.1.7p2: - // "When a value of complex type is converted to a real type, the imaginary - // part of the complex value is discarded and the value of the real part is - // converted according to the conversion rules for the corresponding real - // type. - Value *Src = CGF.EmitComplexExpr(E).first; - return EmitScalarConversion(Src, CT->getElementType(), DestTy); - } - - RValue Src = CGF.EmitAnyExpr(E); - - // If the destination is void, just evaluate the source. - if (DestTy->isVoidType()) return 0; - assert(0 && "Can't convert from an aggregate yet!"); + // Handle cases where the source is a complex type. + + // C99 6.3.1.7p2: "When a value of complex type is converted to a real type, + // the imaginary part of the complex value is discarded and the value of the + // real part is converted according to the conversion rules for the + // corresponding real type. + Value *Src = CGF.EmitComplexExpr(E).first; + return EmitScalarConversion(Src, CT->getElementType(), DestTy); } //===----------------------------------------------------------------------===//