diff options
| author | Anders Carlsson <andersca@mac.com> | 2008-12-10 23:30:05 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2008-12-10 23:30:05 +0000 |
| commit | b05961c700422ae4024d933fb2bd5cd30e816396 (patch) | |
| tree | 3dd87c05ddb17c97d2f109c166c79214b341be08 | |
| parent | d8681df4e7cb2a9faae353ce725854fc28e9a782 (diff) | |
| download | bcm5719-llvm-b05961c700422ae4024d933fb2bd5cd30e816396.tar.gz bcm5719-llvm-b05961c700422ae4024d933fb2bd5cd30e816396.zip | |
Make sure to promote expressions of the form (floating point + complex integer) correctly, to (complex floating point + complex floating point)
llvm-svn: 60862
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Sema/complex-promotion.c | 11 |
2 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3870f0736ec..b2542542417 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -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); diff --git a/clang/test/Sema/complex-promotion.c b/clang/test/Sema/complex-promotion.c new file mode 100644 index 00000000000..a9b557d2217 --- /dev/null +++ b/clang/test/Sema/complex-promotion.c @@ -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]; |

