diff options
| author | Anders Carlsson <andersca@mac.com> | 2009-12-31 18:34:24 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2009-12-31 18:34:24 +0000 |
| commit | e60365b7b5c79536084e99fbea19c91170a41349 (patch) | |
| tree | e5c2c1aa8b98009b16ed19ce4a45035b699c988b /clang/lib/Sema/SemaDeclCXX.cpp | |
| parent | ac61550504de1dd67525b39422db50ba3bec84c9 (diff) | |
| download | bcm5719-llvm-e60365b7b5c79536084e99fbea19c91170a41349.tar.gz bcm5719-llvm-e60365b7b5c79536084e99fbea19c91170a41349.zip | |
Make sure that an overriding return type is complete before checking if it's covariant. Fixes PR5920.
llvm-svn: 92365
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index f8321132ff0..d6aa240df4c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -5528,6 +5528,15 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New, return true; } + // C++ [class.virtual]p6: + // If the return type of D::f differs from the return type of B::f, the + // class type in the return type of D::f shall be complete at the point of + // declaration of D::f or shall be the class type D. + if (RequireCompleteType(New->getLocation(), NewClassTy, + PDiag(diag::err_covariant_return_incomplete) + << New->getDeclName())) + return true; + if (!Context.hasSameUnqualifiedType(NewClassTy, OldClassTy)) { // Check if the new class derives from the old class. if (!IsDerivedFrom(NewClassTy, OldClassTy)) { |

