From 5f951ee8bd723d5fcfeacf6d79b4ebf074069f85 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Fri, 14 Nov 2014 22:09:15 +0000 Subject: Recommit r222044 with a test fix - it does not make sense to hunt for a typedef before arithmetic conversion in all rare corner cases. llvm-svn: 222049 --- clang/lib/Sema/SemaExpr.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'clang/lib/Sema/SemaExpr.cpp') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index dde3f3764f1..1429df778b5 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -5711,7 +5711,7 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, RHS.get()->getType()->isVectorType()) return CheckVectorOperands(LHS, RHS, QuestionLoc, /*isCompAssign*/false); - UsualArithmeticConversions(LHS, RHS); + QualType ResTy = UsualArithmeticConversions(LHS, RHS); if (LHS.isInvalid() || RHS.isInvalid()) return QualType(); @@ -5728,8 +5728,12 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, // If both operands have arithmetic type, do the usual arithmetic conversions // to find a common type: C99 6.5.15p3,5. - if (LHSTy->isArithmeticType() && RHSTy->isArithmeticType()) - return LHS.get()->getType(); + if (LHSTy->isArithmeticType() && RHSTy->isArithmeticType()) { + LHS = ImpCastExprToType(LHS.get(), ResTy, PrepareScalarCast(LHS, ResTy)); + RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy)); + + return ResTy; + } // If both operands are the same structure or union type, the result is that // type. -- cgit v1.2.3