diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-01-19 19:26:10 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-01-19 19:26:10 +0000 |
commit | 4ec339f43c0cae2678334850c90926bea10999c7 (patch) | |
tree | 618cd12f3da4ef770bbd1d79573b85cb4c7eda1b /lib/Sema/SemaNamedCast.cpp | |
parent | fec7c2a9d0d46f4e681d1fe0089ae590962f05f6 (diff) |
Centralize error reporting of improper uses of incomplete types in the
new DiagnoseIncompleteType. It provides additional information about
struct/class/union/enum types when possible, either by pointing to the
forward declaration of that type or by pointing to the definition (if
we're in the process of defining that type).
Fixes <rdar://problem/6500531>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62521 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaNamedCast.cpp')
-rw-r--r-- | lib/Sema/SemaNamedCast.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp index 3d3572d00c..06fc9d83ba 100644 --- a/lib/Sema/SemaNamedCast.cpp +++ b/lib/Sema/SemaNamedCast.cpp @@ -685,11 +685,10 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, if (DestPointee->isVoidType()) { assert(DestPointer && "Reference to void is not possible"); } else if (DestRecord) { - if (!DestRecord->getDecl()->isDefinition()) { - Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_incomplete) - << DestPointee.getUnqualifiedType() << DestRange; + if (Self.DiagnoseIncompleteType(OpRange.getBegin(), DestPointee, + diag::err_bad_dynamic_cast_incomplete, + DestRange)) return; - } } else { Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class) << DestPointee.getUnqualifiedType() << DestRange; @@ -720,11 +719,10 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, const RecordType *SrcRecord = SrcPointee->getAsRecordType(); if (SrcRecord) { - if (!SrcRecord->getDecl()->isDefinition()) { - Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_incomplete) - << SrcPointee.getUnqualifiedType() << SrcExpr->getSourceRange(); + if (Self.DiagnoseIncompleteType(OpRange.getBegin(), SrcPointee, + diag::err_bad_dynamic_cast_incomplete, + SrcExpr->getSourceRange())) return; - } } else { Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class) << SrcPointee.getUnqualifiedType() << SrcExpr->getSourceRange(); |