diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-01-15 01:41:59 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-01-15 01:41:59 +0000 |
| commit | 7f988889ef8a6eb4e7779947da3692885fb36726 (patch) | |
| tree | d6b58f7c4f9ac92fe5bc4000b0bdc63e7f44309b /clang/Sema/SemaExpr.cpp | |
| parent | e5843597164f0d3958b8375aaf25c4ffa5eca1d0 (diff) | |
| download | bcm5719-llvm-7f988889ef8a6eb4e7779947da3692885fb36726.tar.gz bcm5719-llvm-7f988889ef8a6eb4e7779947da3692885fb36726.zip | |
Rework commit r45976, which was incorrect.
- Add Type::isComplexIntegerType(), Type::getAsComplexIntegerType().
- Don't inlude complex types with Type::isIntegerType(), which is too general.
- Use the new predicates in Sema::UsualArithmeticConversions() to recognize/convert the types.
llvm-svn: 45992
Diffstat (limited to 'clang/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/Sema/SemaExpr.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp index 9f5e8e68b89..436510f763c 100644 --- a/clang/Sema/SemaExpr.cpp +++ b/clang/Sema/SemaExpr.cpp @@ -951,12 +951,25 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr, // Handle complex types first (C99 6.3.1.8p1). if (lhs->isComplexType() || rhs->isComplexType()) { - // if we have an integer operand, the result is the complex type. - if (rhs->isIntegerType()) { // convert the rhs to the lhs complex type. + // Handle GCC complex int extension first. + // FIXME: need to verify these conversion rules are consistent with GCC. + const ComplexType *lhsComplexInt = lhs->getAsComplexIntegerType(); + const ComplexType *rhsComplexInt = rhs->getAsComplexIntegerType(); + + if (lhsComplexInt && rhsComplexInt) { + if (Context.maxIntegerType(lhsComplexInt->getElementType(), + rhsComplexInt->getElementType()) == lhs) { + if (!isCompAssign) promoteExprToType(rhsExpr, lhs); // convert the rhs + return lhs; + } + if (!isCompAssign) promoteExprToType(lhsExpr, rhs); // convert the lhs + return rhs; + } else if (lhsComplexInt && rhs->isIntegerType()) { + // convert the rhs to the lhs complex type. if (!isCompAssign) promoteExprToType(rhsExpr, lhs); return lhs; - } - if (lhs->isIntegerType()) { // convert the lhs to the rhs complex type. + } else if (rhsComplexInt && lhs->isIntegerType()) { + // convert the lhs to the rhs complex type. if (!isCompAssign) promoteExprToType(lhsExpr, rhs); return rhs; } |

