Check that the destination type of a static_cast expression is a complete type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81151 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index d88bbeb..ceb2de7 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/lib/Sema/SemaCXXCast.cpp
@@ -759,6 +759,14 @@
bool CStyle, const SourceRange &OpRange, unsigned &msg,
CXXMethodDecl *&ConversionDecl)
{
+ if (DestType->isRecordType()) {
+ if (Self.RequireCompleteType(OpRange.getBegin(), DestType,
+ diag::err_bad_dynamic_cast_incomplete)) {
+ msg = 0;
+ return TC_Failed;
+ }
+ }
+
if (DestType->isReferenceType()) {
// At this point of CheckStaticCast, if the destination is a reference,
// this has to work. There is no other way that works.