aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-05-14 22:15:41 +0000
committerAnders Carlsson <andersca@mac.com>2009-05-14 22:15:41 +0000
commit77b7f1d4fb782c9152f91b76f9f8b1d1af21bd35 (patch)
tree7e40dbdd2b136b3e3dadad70d31c778a0b746fbb /lib/Sema/SemaDecl.cpp
parenta75e8534f2b7c2480c48f31f301bd00b241c5499 (diff)
Check that the function being overridden is virtual.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 1c464d16b0..feb9595736 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/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.