Improved MSVC __interface support by adding first class support for it, instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163013 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 176e3fe..bae03f2 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -672,12 +672,28 @@
                                    isa<CXXConstructorDecl>(FD)))
       return false;
   }
-  return true;
-}
-
-// CheckConstexprFunctionDecl - Check whether a function declaration satisfies
-// the requirements of a constexpr function definition or a constexpr
-// constructor definition. If so, return true. If not, produce appropriate
+  return true;

+}

+

+/// \brief Get diagnostic %select index for tag kind for

+/// record diagnostic message.

+/// WARNING: Indexes apply to particular diagnostics only!

+///

+/// \returns diagnostic %select index.

+static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)

+{

+  switch (Tag) {

+    case TTK_Struct: return 0;

+    case TTK_Interface: return 1;

+    case TTK_Class:  return 2;

+    default: assert("Invalid tag kind for record diagnostic!");

+  }

+  return -1;

+}

+

+// CheckConstexprFunctionDecl - Check whether a function declaration satisfies

+// the requirements of a constexpr function definition or a constexpr

+// constructor definition. If so, return true. If not, produce appropriate

 // diagnostics and return false.
 //
 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
@@ -688,14 +704,14 @@
     //  The definition of a constexpr constructor shall satisfy the following
     //  constraints:
     //  - the class shall not have any virtual base classes;
-    const CXXRecordDecl *RD = MD->getParent();
-    if (RD->getNumVBases()) {
-      Diag(NewFD->getLocation(), diag::err_constexpr_virtual_base)
-        << isa<CXXConstructorDecl>(NewFD) << RD->isStruct()
-        << RD->getNumVBases();
-      for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),
-             E = RD->vbases_end(); I != E; ++I)
-        Diag(I->getLocStart(),
+    const CXXRecordDecl *RD = MD->getParent();

+    if (RD->getNumVBases()) {

+      Diag(NewFD->getLocation(), diag::err_constexpr_virtual_base)

+        << isa<CXXConstructorDecl>(NewFD)

+        << getRecordDiagFromTagKind(RD->getTagKind()) << RD->getNumVBases();

+      for (CXXRecordDecl::base_class_const_iterator I = RD->vbases_begin(),

+             E = RD->vbases_end(); I != E; ++I)

+        Diag(I->getLocStart(),

              diag::note_constexpr_virtual_base_here) << I->getSourceRange();
       return false;
     }