It's perfectly fine to see UserDefinedConversion casts when emitting scalar expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91686 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 07909fa..0a06907 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -816,6 +816,7 @@
     return Builder.CreateBitCast(Src, ConvertType(DestTy));
   }
   case CastExpr::CK_NoOp:
+  case CastExpr::CK_UserDefinedConversion:
     return Visit(const_cast<Expr*>(E));
 
   case CastExpr::CK_BaseToDerived: {
@@ -903,7 +904,6 @@
     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 ef45fc2..fccb6f0 100644
--- a/test/CodeGenCXX/conversion-function.cpp
+++ b/test/CodeGenCXX/conversion-function.cpp
@@ -12,6 +12,9 @@
   return 10;
 }
 
+int f(S s) {
+  return s;
+}
 
 class X { // ...
   public: operator int() { printf("operator int()\n"); return iX; }
@@ -94,6 +97,9 @@
   char ch = a;  // OK. calls Yb::operator char();
 }
 
+struct A {
+  operator int() const;
+};
 
 // CHECK-LP64: .globl __ZN1ScviEv
 // CHECK-LP64-NEXT: __ZN1ScviEv: