From: Anders Carlsson Date: Thu, 20 Jan 2011 06:52:44 +0000 (+0000) Subject: When instantiating member functions, propagate whether the member function is marked... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9eefa229dfb71400a6bbee326420a7f0e2e91f1f;p=clang When instantiating member functions, propagate whether the member function is marked 'final' and 'override'. Also, call CheckOverrideControl when instantiating member functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123900 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index fd7325cc01..36a1900299 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1393,8 +1393,12 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, if (D->isPure()) SemaRef.CheckPureMethod(Method, SourceRange()); + Method->setIsMarkedOverride(D->isMarkedOverride()); + Method->setIsMarkedFinal(D->isMarkedFinal()); Method->setAccess(D->getAccess()); + SemaRef.CheckOverrideControl(Method); + if (FunctionTemplate) { // If there's a function template, let our caller handle it. } else if (Method->isInvalidDecl() && !Previous.empty()) { diff --git a/test/CXX/class.derived/class.virtual/p3-0x.cpp b/test/CXX/class.derived/class.virtual/p3-0x.cpp index 773b9f6077..d49d06cbdd 100644 --- a/test/CXX/class.derived/class.virtual/p3-0x.cpp +++ b/test/CXX/class.derived/class.virtual/p3-0x.cpp @@ -24,3 +24,19 @@ struct B : A { }; } + +namespace Test3 { + +struct A { + virtual void f(int, char, int); +}; + +template +struct B : A { + virtual void f(Args...) override; // expected-error {{'f' marked 'override' but does not override any member functions}} +}; + +template struct B; +template struct B; // expected-note {{in instantiation of template class 'Test3::B' requested here}} + +}