Sema-check virtual declarations. Complete dynamic_cast checking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58804 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp
index 980e012..bf559d6 100644
--- a/lib/Sema/SemaNamedCast.cpp
+++ b/lib/Sema/SemaNamedCast.cpp
@@ -671,7 +671,12 @@
   }
 
   // C++ 5.2.7p6: Otherwise, v shall be [polymorphic].
-  // FIXME: Information not yet available.
+  const RecordDecl *SrcDecl = SrcRecord->getDecl()->getDefinition(Context);
+  assert(SrcDecl && "Definition missing");
+  if (!cast<CXXRecordDecl>(SrcDecl)->isPolymorphic()) {
+    Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_polymorphic,
+      SrcPointee.getUnqualifiedType().getAsString(), SrcExpr->getSourceRange());
+  }
 
   // Done. Everything else is run-time checks.
 }