diff options
author | Anders Carlsson <andersca@mac.com> | 2009-05-14 22:15:41 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-05-14 22:15:41 +0000 |
commit | 0a7c01ff2b2b42c22e25733bf6c961cdf6ad5166 (patch) | |
tree | e5babbe6217d0b19c365fa16879e12878c8bd7b4 /clang/lib/Sema/SemaDecl.cpp | |
parent | 98ed3c7273cbccb69ed322fe2223f3bccd5b7850 (diff) | |
download | bcm5719-llvm-0a7c01ff2b2b42c22e25733bf6c961cdf6ad5166.tar.gz bcm5719-llvm-0a7c01ff2b2b42c22e25733bf6c961cdf6ad5166.zip |
Check that the function being overridden is virtual.
llvm-svn: 71802
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1c464d16b05..feb9595736f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2125,7 +2125,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, SourceRange(D.getDeclSpec().getVirtualSpecLoc())); } else { // Okay: Add virtual to the method. - cast<CXXMethodDecl>(NewFD)->setVirtual(); + cast<CXXMethodDecl>(NewFD)->setVirtualAsWritten(true); CXXRecordDecl *CurClass = cast<CXXRecordDecl>(DC); CurClass->setAggregate(false); CurClass->setPOD(false); @@ -2152,6 +2152,8 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // FIXME: Is this OK? Should it be done by LookupInBases? if (IsOverload(NewMD, OldMD, MatchedDecl)) continue; + if (!OldMD->isVirtual()) + continue; if (!CheckOverridingFunctionReturnType(NewMD, OldMD)) { // FIXME: Add OldMD to the list of methods NewMD overrides. @@ -2490,7 +2492,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) { Expr *Init = static_cast<Expr *>(init.get()); if ((IL = dyn_cast<IntegerLiteral>(Init)) && IL->getValue() == 0 && Context.getCanonicalType(IL->getType()) == Context.IntTy) { - if (Method->isVirtual()) { + if (Method->isVirtualAsWritten()) { Method->setPure(); // A class is abstract if at least one function is pure virtual. |