Require a class type to be complete before probing its conversion
functions for a switch condition's conversion to integral or
enumeration type. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89656 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index b674a17..ad3376b 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -391,6 +391,13 @@
     // conversion is used in place of the original condition for the remainder
     // of this section. Integral promotions are performed.
     if (!CondExpr->isTypeDependent()) {
+      // Make sure that the condition expression has a complete type,
+      // otherwise we'll never find any conversions.
+      if (RequireCompleteType(SwitchLoc, CondType,
+                              PDiag(diag::err_switch_incomplete_class_type)
+                                << CondExpr->getSourceRange()))
+        return StmtError();
+
       llvm::SmallVector<CXXConversionDecl *, 4> ViableConversions;
       llvm::SmallVector<CXXConversionDecl *, 4> ExplicitConversions;
       if (const RecordType *RecordTy = CondType->getAs<RecordType>()) {