// 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;
///
/// 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)
return false;
return IsFloatingPointPromotion(FromComplex->getElementType(),
- ToComplex->getElementType());
+ ToComplex->getElementType()) ||
+ IsIntegralPromotion(0, FromComplex->getElementType(),
+ ToComplex->getElementType());
}
/// BuildSimilarlyQualifiedPointerType - In a pointer conversion from
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);
+}