[cfe-commits] r41515 - /cfe/trunk/Sema/SemaExpr.cpp
Steve Naroff
snaroff at apple.com
Mon Aug 27 14:32:55 PDT 2007
Author: snaroff
Date: Mon Aug 27 16:32:55 2007
New Revision: 41515
URL: http://llvm.org/viewvc/llvm-project?rev=41515&view=rev
Log:
Fix remaining bugs with complex/float promotions.
Modified:
cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=41515&r1=41514&r2=41515&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Mon Aug 27 16:32:55 2007
@@ -824,23 +824,32 @@
int result = Context.compareFloatingType(lhs, rhs);
if (result > 0) { // The left side is bigger, convert rhs.
- QualType tMax = Context.getFloatingTypeOfSizeWithinDomain(lhs, rhs);
- if (!isCompAssign) promoteExprToType(rhsExpr, tMax);
- return tMax;
- }
- if (result < 0) { // The right side is bigger, convert lhs.
- QualType tMax = Context.getFloatingTypeOfSizeWithinDomain(rhs, lhs);
- if (!isCompAssign) promoteExprToType(lhsExpr, tMax);
- return tMax;
- }
- // The floating point types were ranked equally.
- if (lhs->isComplexType()) { // handle "_Complex double, double".
- if (!isCompAssign) promoteExprToType(rhsExpr, lhs);
- return lhs;
+ rhs = Context.getFloatingTypeOfSizeWithinDomain(lhs, rhs);
+ if (!isCompAssign)
+ promoteExprToType(rhsExpr, rhs);
+ } else if (result < 0) { // The right side is bigger, convert lhs.
+ lhs = Context.getFloatingTypeOfSizeWithinDomain(rhs, lhs);
+ if (!isCompAssign)
+ promoteExprToType(lhsExpr, lhs);
+ }
+ // At this point, lhs and rhs have the same rank/size. Now, make sure the
+ // domains match. This is a requirement for our implementation, C99
+ // does not require this promotion.
+ if (lhs != rhs) { // Domains don't match, we have complex/float mix.
+ if (lhs->isRealFloatingType()) { // handle "double, _Complex double".
+ if (isCompAssign)
+ return rhs;
+ promoteExprToType(lhsExpr, rhs);
+ } else { // handle "_Complex double, double".
+ if (isCompAssign)
+ return lhs;
+ promoteExprToType(rhsExpr, lhs);
+ }
+ // Both expressions now have the same rank/domain.
+ return lhsExpr->getType();
}
- // The right side is complex, handle "double, _Complex double".
- if (!isCompAssign) promoteExprToType(lhsExpr, rhs);
- return rhs;
+ // The domain/size match, simply return lhs (which may have been converted).
+ return lhs;
}
// Now handle "real" floating types (i.e. float, double, long double).
if (lhs->isRealFloatingType() || rhs->isRealFloatingType()) {
More information about the cfe-commits
mailing list