[cfe-commits] r124040 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiate.cpp test/CXX/class/p2-0x.cpp

Anders Carlsson andersca at mac.com
Sat Jan 22 10:07:06 PST 2011


Author: andersca
Date: Sat Jan 22 12:07:06 2011
New Revision: 124040

URL: http://llvm.org/viewvc/llvm-project?rev=124040&view=rev
Log:
Mark classes final and/or explicit during class template instantiation.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/trunk/test/CXX/class/p2-0x.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=124040&r1=124039&r2=124040&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Sat Jan 22 12:07:06 2011
@@ -1640,6 +1640,9 @@
   
   Instantiation->setTagKind(Pattern->getTagKind());
 
+  Instantiation->setIsMarkedFinal(Pattern->isMarkedFinal());
+  Instantiation->setIsMarkedExplicit(Pattern->isMarkedExplicit());
+
   // Do substitution on the base class specifiers.
   if (SubstBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
     Invalid = true;

Modified: cfe/trunk/test/CXX/class/p2-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/p2-0x.cpp?rev=124040&r1=124039&r2=124040&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class/p2-0x.cpp (original)
+++ cfe/trunk/test/CXX/class/p2-0x.cpp Sat Jan 22 12:07:06 2011
@@ -6,3 +6,23 @@
 
 }
 
+namespace Test2 {
+
+template<typename T> struct A final { }; // expected-note 2 {{'A' declared here}}
+struct B : A<int> { }; // expected-error {{base 'A' is marked 'final'}}
+  
+template<typename T> struct C : A<T> { }; // expected-error {{base 'A' is marked 'final'}}
+struct D : C<int> { }; // expected-note {{in instantiation of template class 'Test2::C<int>' requested here}}
+
+}
+
+namespace Test3 {
+
+template<typename T> struct A { };
+template<> struct A<int> final { }; // expected-note {{'A' declared here}}
+
+struct B : A<bool> { };
+struct C : A<int> { }; // expected-error {{base 'A' is marked 'final'}}
+
+}
+





More information about the cfe-commits mailing list