]> granicus.if.org Git - clang/commitdiff
Properly do a float -> _Complex double conversion, fixes rdar://8875946.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 18 Jan 2011 18:49:33 +0000 (18:49 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 18 Jan 2011 18:49:33 +0000 (18:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123759 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/const-eval.c

index 45e0c3377b830ba0b097310467bb13a9603b83e8..e2e802c7901c586a5b4894e322f0654daf3f3d1e 100644 (file)
@@ -528,7 +528,8 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr,
     if (order < 0) { // RHS is wider
       // float -> _Complex double
       if (!isCompAssign) {
-        ImpCastExprToType(lhsExpr, rhs, CK_FloatingCast);
+        QualType fp = cast<ComplexType>(rhs)->getElementType();
+        ImpCastExprToType(lhsExpr, fp, CK_FloatingCast);
         ImpCastExprToType(lhsExpr, rhs, CK_FloatingRealToComplex);
       }
       return rhs;
index 9f2d32769fb3a21ed00ec30a26634806042f83e1..aa0cee5da5b34b303d9e871d9e6b4bb424a6d9e1 100644 (file)
@@ -80,3 +80,9 @@ EVAL_EXPR(38, __builtin_expect(1,1) == 1 ? 1 : -1)
 // PR7884
 EVAL_EXPR(39, __real__(1.f) == 1 ? 1 : -1)
 EVAL_EXPR(40, __imag__(1.f) == 0 ? 1 : -1)
+
+// rdar://8875946
+void rdar8875946() {
+  double _Complex  P;
+  float _Complex  P2 = 3.3f + P;
+}