]> granicus.if.org Git - clang/commitdiff
When instantiating member functions, propagate whether the member function is marked...
authorAnders Carlsson <andersca@mac.com>
Thu, 20 Jan 2011 06:52:44 +0000 (06:52 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 20 Jan 2011 06:52:44 +0000 (06:52 +0000)
Also, call CheckOverrideControl when instantiating member functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123900 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/CXX/class.derived/class.virtual/p3-0x.cpp

index fd7325cc01d913425dba7664791563637470bcc8..36a190029935969c7baa563c6037066e3587b3fb 100644 (file)
@@ -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()) {
index 773b9f6077faebe1ef2fa49547d414ffb16d31ce..d49d06cbddbd783e3570403e46a1e8923f1d38fd 100644 (file)
@@ -24,3 +24,19 @@ struct B : A {
 };
 
 }
+
+namespace Test3 {
+
+struct A {
+  virtual void f(int, char, int);
+};
+
+template<typename... Args>
+struct B : A { 
+  virtual void f(Args...) override; // expected-error {{'f' marked 'override' but does not override any member functions}}
+};
+
+template struct B<int, char, int>;
+template struct B<int>; // expected-note {{in instantiation of template class 'Test3::B<int>' requested here}}
+
+}