diff options
author | Anders Carlsson <andersca@mac.com> | 2009-03-24 01:19:16 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-03-24 01:19:16 +0000 |
commit | b5a27b460c6a53f93aff0d315b21b9c241e1ac95 (patch) | |
tree | 80fb46253ea252d4b8fe41e6e651a3c76117c602 /clang/lib/Sema/SemaDecl.cpp | |
parent | 94c25c66b5ed45f579953e5efaaa4a11ac47d847 (diff) | |
download | bcm5719-llvm-b5a27b460c6a53f93aff0d315b21b9c241e1ac95.tar.gz bcm5719-llvm-b5a27b460c6a53f93aff0d315b21b9c241e1ac95.zip |
More work on diagnosing abstract classes. We can now handle cases like
class C {
void g(C c);
virtual void f() = 0;
};
In this case, C is not known to be abstract when doing semantic analysis on g. This is done by recursively traversing the abstract class and checking the types of member functions.
llvm-svn: 67594
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index ccc31974463..a3b60047d62 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1643,7 +1643,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, // The variable can not have an abstract class type. if (RequireNonAbstractType(D.getIdentifierLoc(), R, diag::err_abstract_type_in_decl, - 2 /* variable type */)) + AbstractVariableType)) InvalidDecl = true; // The variable can not @@ -1815,11 +1815,14 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, bool isExplicit = D.getDeclSpec().isExplicitSpecified(); // Check that the return type is not an abstract class type. - if (RequireNonAbstractType(D.getIdentifierLoc(), + // For record types, this is done by the AbstractClassUsageDiagnoser once + // the class has been completely parsed. + if (!DC->isRecord() && + RequireNonAbstractType(D.getIdentifierLoc(), R->getAsFunctionType()->getResultType(), diag::err_abstract_type_in_decl, - 0 /* return type */)) - InvalidDecl = true; + AbstractReturnType)) + InvalidDecl = true; bool isVirtualOkay = false; FunctionDecl *NewFD; @@ -2609,9 +2612,12 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { } // Parameters can not be abstract class types. - if (RequireNonAbstractType(D.getIdentifierLoc(), parmDeclType, + // For record types, this is done by the AbstractClassUsageDiagnoser once + // the class has been completely parsed. + if (!CurContext->isRecord() && + RequireNonAbstractType(D.getIdentifierLoc(), parmDeclType, diag::err_abstract_type_in_decl, - 1 /* parameter type */)) + AbstractParamType)) D.setInvalidType(true); QualType T = adjustParameterType(parmDeclType); @@ -3544,7 +3550,7 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, // Fields can not have abstract class types if (RequireNonAbstractType(Loc, T, diag::err_abstract_type_in_decl, - 3 /* field type */)) + AbstractFieldType)) InvalidDecl = true; // If this is declared as a bit-field, check the bit-field. |