Make sure to promote expressions of the form (floating point + complex integer) correctly, to (complex floating point + complex floating point)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60862 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 3870f07..b254254 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -189,14 +189,22 @@
// Now handle "real" floating types (i.e. float, double, long double).
if (lhs->isRealFloatingType() || rhs->isRealFloatingType()) {
// if we have an integer operand, the result is the real floating type.
- if (rhs->isIntegerType() || rhs->isComplexIntegerType()) {
+ if (rhs->isIntegerType()) {
// convert rhs to the lhs floating point type.
return lhs;
}
- if (lhs->isIntegerType() || lhs->isComplexIntegerType()) {
+ if (rhs->isComplexIntegerType()) {
+ // convert rhs to the complex floating point type.
+ return Context.getComplexType(lhs);
+ }
+ if (lhs->isIntegerType()) {
// convert lhs to the rhs floating point type.
return rhs;
}
+ if (lhs->isComplexIntegerType()) {
+ // convert lhs to the complex floating point type.
+ return Context.getComplexType(rhs);
+ }
// We have two real floating types, float/complex combos were handled above.
// Convert the smaller operand to the bigger result.
int result = Context.getFloatingTypeOrder(lhs, rhs);