From d3a505827fd8775ce479498e5726b484336eedd8 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 1 Dec 2009 16:18:00 +0000 Subject: [PATCH] An inherited virtual (where "virtual" wasn't written explicitly) can be defined as pure. Fixes PR5656. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90237 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 2 +- test/SemaCXX/virtual-override.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 520d7de710..2087f8b8c6 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3393,7 +3393,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) { Expr *Init = static_cast(init.get()); if ((IL = dyn_cast(Init)) && IL->getValue() == 0 && Context.getCanonicalType(IL->getType()) == Context.IntTy) { - if (Method->isVirtualAsWritten()) { + if (Method->isVirtual()) { Method->setPure(); // A class is abstract if at least one function is pure virtual. diff --git a/test/SemaCXX/virtual-override.cpp b/test/SemaCXX/virtual-override.cpp index 4a3b10fa97..7ace886ff0 100644 --- a/test/SemaCXX/virtual-override.cpp +++ b/test/SemaCXX/virtual-override.cpp @@ -104,3 +104,11 @@ namespace T7 { virtual b* f(); }; } + +// PR5656 +class X0 { + virtual void f0(); +}; +class X1 : public X0 { + void f0() = 0; +};