Make sure to promote expressions of the form (floating point + complex integer) correctly, to (complex floating point + complex floating point)

llvm-svn: 60862
This commit is contained in:
Anders Carlsson 2008-12-10 23:30:05 +00:00
parent d8681df4e7
commit b05961c700
2 changed files with 21 additions and 2 deletions

View File

@ -189,14 +189,22 @@ QualType Sema::UsualArithmeticConversionsType(QualType lhs, QualType rhs) {
// 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);

View File

@ -0,0 +1,11 @@
// RUN: clang %s -verify -fsyntax-only
float a;
int b[__builtin_classify_type(a + 1i) == 9 ? 1 : -1];
int c[__builtin_classify_type(1i + a) == 9 ? 1 : -1];
double d;
__typeof__ (d + 1i) e;
int f[sizeof(e) == 2 * sizeof(double) ? 1 : -1];