From: Anders Carlsson Date: Sat, 22 Jan 2011 18:07:06 +0000 (+0000) Subject: Mark classes final and/or explicit during class template instantiation. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7028088b4bce6fa4660232698068d4cc7b0ab698;p=clang Mark classes final and/or explicit during class template instantiation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124040 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 45fde296e3..2102073682 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -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; diff --git a/test/CXX/class/p2-0x.cpp b/test/CXX/class/p2-0x.cpp index 1164b8f0a2..630aa7e70f 100644 --- a/test/CXX/class/p2-0x.cpp +++ b/test/CXX/class/p2-0x.cpp @@ -6,3 +6,23 @@ class B : A { }; // expected-error {{base 'A' is marked 'final'}} } +namespace Test2 { + +template struct A final { }; // expected-note 2 {{'A' declared here}} +struct B : A { }; // expected-error {{base 'A' is marked 'final'}} + +template struct C : A { }; // expected-error {{base 'A' is marked 'final'}} +struct D : C { }; // expected-note {{in instantiation of template class 'Test2::C' requested here}} + +} + +namespace Test3 { + +template struct A { }; +template<> struct A final { }; // expected-note {{'A' declared here}} + +struct B : A { }; +struct C : A { }; // expected-error {{base 'A' is marked 'final'}} + +} +