[cfe-commits] r123900 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/CXX/class.derived/class.virtual/p3-0x.cpp

Anders Carlsson andersca at mac.com
Wed Jan 19 22:52:44 PST 2011


Author: andersca
Date: Thu Jan 20 00:52:44 2011
New Revision: 123900

URL: http://llvm.org/viewvc/llvm-project?rev=123900&view=rev
Log:
When instantiating member functions, propagate whether the member function is marked 'final' and 'override'.

Also, call CheckOverrideControl when instantiating member functions.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/CXX/class.derived/class.virtual/p3-0x.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=123900&r1=123899&r2=123900&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Jan 20 00:52:44 2011
@@ -1393,8 +1393,12 @@
   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()) {

Modified: cfe/trunk/test/CXX/class.derived/class.virtual/p3-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.derived/class.virtual/p3-0x.cpp?rev=123900&r1=123899&r2=123900&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.derived/class.virtual/p3-0x.cpp (original)
+++ cfe/trunk/test/CXX/class.derived/class.virtual/p3-0x.cpp Thu Jan 20 00:52:44 2011
@@ -24,3 +24,19 @@
 };
 
 }
+
+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}}
+
+}





More information about the cfe-commits mailing list