From: Eli Friedman Date: Sat, 12 Nov 2011 03:56:23 +0000 (+0000) Subject: Add missing casts to AST. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ddadaa4579dbb12dcfad62ee86e1e52e12f298ee;p=clang Add missing casts to AST. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144455 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index a5b766ad73..d22a431d06 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -823,14 +823,21 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, if (LHSComplexInt) { // int -> _Complex int + // FIXME: This needs to take integer ranks into account + RHS = S.ImpCastExprToType(RHS.take(), LHSComplexInt->getElementType(), + CK_IntegralCast); RHS = S.ImpCastExprToType(RHS.take(), LHSType, CK_IntegralRealToComplex); return LHSType; } assert(RHSComplexInt); // int -> _Complex int - if (!IsCompAssign) + // FIXME: This needs to take integer ranks into account + if (!IsCompAssign) { + LHS = S.ImpCastExprToType(LHS.take(), RHSComplexInt->getElementType(), + CK_IntegralCast); LHS = S.ImpCastExprToType(LHS.take(), RHSType, CK_IntegralRealToComplex); + } return RHSType; } diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index b188578420..632457da09 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -81,6 +81,9 @@ EVAL_EXPR(38, __builtin_expect(1,1) == 1 ? 1 : -1) EVAL_EXPR(39, __real__(1.f) == 1 ? 1 : -1) EVAL_EXPR(40, __imag__(1.f) == 0 ? 1 : -1) +// From gcc testsuite +EVAL_EXPR(41, (int)(1+(_Complex unsigned)2)) + // rdar://8875946 void rdar8875946() { double _Complex P;