diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 07909faa75..0a0690754f 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -816,6 +816,7 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { return Builder.CreateBitCast(Src, ConvertType(DestTy)); } case CastExpr::CK_NoOp: + case CastExpr::CK_UserDefinedConversion: return Visit(const_cast(E)); case CastExpr::CK_BaseToDerived: { @@ -903,7 +904,6 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { return Src; } - case CastExpr::CK_UserDefinedConversion: case CastExpr::CK_ConstructorConversion: assert(0 && "Should be unreachable!"); break; diff --git a/test/CodeGenCXX/conversion-function.cpp b/test/CodeGenCXX/conversion-function.cpp index ef45fc2342..fccb6f094e 100644 --- a/test/CodeGenCXX/conversion-function.cpp +++ b/test/CodeGenCXX/conversion-function.cpp @@ -12,6 +12,9 @@ S::operator int() { return 10; } +int f(S s) { + return s; +} class X { // ... public: operator int() { printf("operator int()\n"); return iX; } @@ -94,6 +97,9 @@ void f(Yb& a) { char ch = a; // OK. calls Yb::operator char(); } +struct A { + operator int() const; +}; // CHECK-LP64: .globl __ZN1ScviEv // CHECK-LP64-NEXT: __ZN1ScviEv: