[cfe-commits] r64344 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/complex-overload.cpp
Douglas Gregor
dgregor at apple.com
Wed Feb 11 16:26:06 PST 2009
Author: dgregor
Date: Wed Feb 11 18:26:06 2009
New Revision: 64344
URL: http://llvm.org/viewvc/llvm-project?rev=64344&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/complex-overload.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=64344&r1=64343&r2=64344&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Feb 11 18:26:06 2009
@@ -738,7 +738,9 @@
// 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 @@
///
/// 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 @@
return false;
return IsFloatingPointPromotion(FromComplex->getElementType(),
- ToComplex->getElementType());
+ ToComplex->getElementType()) ||
+ IsIntegralPromotion(0, FromComplex->getElementType(),
+ ToComplex->getElementType());
}
/// BuildSimilarlyQualifiedPointerType - In a pointer conversion from
Modified: cfe/trunk/test/SemaCXX/complex-overload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/complex-overload.cpp?rev=64344&r1=64343&r2=64344&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/complex-overload.cpp (original)
+++ cfe/trunk/test/SemaCXX/complex-overload.cpp Wed Feb 11 18:26:06 2009
@@ -38,6 +38,13 @@
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);
+}
More information about the cfe-commits
mailing list