]> granicus.if.org Git - clang/commitdiff
Mark classes final and/or explicit during class template instantiation.
authorAnders Carlsson <andersca@mac.com>
Sat, 22 Jan 2011 18:07:06 +0000 (18:07 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 22 Jan 2011 18:07:06 +0000 (18:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124040 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiate.cpp
test/CXX/class/p2-0x.cpp

index 45fde296e3cc13afc4f6659cfadd881f224a955f..2102073682da533b4093b1e88308b31dc1d4cf82 100644 (file)
@@ -1640,6 +1640,9 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
   
   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;
index 1164b8f0a2f838e01db32f362f4f4d89f7757934..630aa7e70f90c338a619d7efc6dee8afc20d2d02 100644 (file)
@@ -6,3 +6,23 @@ class B : A { }; // expected-error {{base 'A' is marked 'final'}}
 
 }
 
+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'}}
+
+}
+