aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-12 00:26:06 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-12 00:26:06 +0000
commitb7b5d13de34272b31681e7eafa9851e39bde2ef9 (patch)
treeaba50fd7bed1e636c6a5103972786c468543d259
parent5cdf82164dd7c2b2320d6735c63ace4331e0716d (diff)
Expand the definition of a complex promotion to include complex ->
complex conversions where the conversion between the real types is an integral promotion. This is how G++ handles complex promotions for its complex integer extension. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64344 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaOverload.cpp10
-rw-r--r--test/SemaCXX/complex-overload.cpp9
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 48d31056a7..c96fec70bb 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -738,7 +738,9 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
// the bit-field is larger yet, no integral promotion applies to
// it. If the bit-field has an enumerated type, it is treated as any
// other value of that type for promotion purposes (C++ 4.5p3).
- if (MemberExpr *MemRef = dyn_cast<MemberExpr>(From)) {
+ // FIXME: We should delay checking of bit-fields until we actually
+ // perform the conversion.
+ if (MemberExpr *MemRef = dyn_cast_or_null<MemberExpr>(From)) {
using llvm::APSInt;
if (FieldDecl *MemberDecl = dyn_cast<FieldDecl>(MemRef->getMemberDecl())) {
APSInt BitWidth;
@@ -803,7 +805,7 @@ bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType)
///
/// A complex promotion is defined as a complex -> complex conversion
/// where the conversion between the underlying real types is a
-/// floating-point conversion.
+/// floating-point or integral promotion.
bool Sema::IsComplexPromotion(QualType FromType, QualType ToType) {
const ComplexType *FromComplex = FromType->getAsComplexType();
if (!FromComplex)
@@ -814,7 +816,9 @@ bool Sema::IsComplexPromotion(QualType FromType, QualType ToType) {
return false;
return IsFloatingPointPromotion(FromComplex->getElementType(),
- ToComplex->getElementType());
+ ToComplex->getElementType()) ||
+ IsIntegralPromotion(0, FromComplex->getElementType(),
+ ToComplex->getElementType());
}
/// BuildSimilarlyQualifiedPointerType - In a pointer conversion from
diff --git a/test/SemaCXX/complex-overload.cpp b/test/SemaCXX/complex-overload.cpp
index 4d27a207ce..300d3499b3 100644
--- a/test/SemaCXX/complex-overload.cpp
+++ b/test/SemaCXX/complex-overload.cpp
@@ -38,6 +38,13 @@ void test_promote_or_convert(float f, float _Complex fc) {
char *promote_or_convert2(float);
int *promote_or_convert2(double _Complex);
-void test_promote_or_convert(float _Complex fc) {
+void test_promote_or_convert2(float _Complex fc) {
int *cp = promote_or_convert2(fc);
}
+
+char *promote_or_convert3(int _Complex);
+int *promote_or_convert3(long _Complex);
+
+void test_promote_or_convert3(short _Complex sc) {
+ char *cp = promote_or_convert3(sc);
+}