diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-23 00:49:01 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-23 00:49:01 +0000 |
commit | 234ff47366f6ae6acdd22b7b83ce91044561da60 (patch) | |
tree | f99714c5be870edc4f250c9ceec4bc54d6959bbe /clang/lib | |
parent | 7949a8b8ea3947043ef39929c5e080ca3d557fa3 (diff) | |
download | bcm5719-llvm-234ff47366f6ae6acdd22b7b83ce91044561da60.tar.gz bcm5719-llvm-234ff47366f6ae6acdd22b7b83ce91044561da60.zip |
[modules] Put class template declarations into the scope in which they're
declared, rather than putting them into the template parameter scope. We
previously had *no record* in the scope for class template declarations, once
those declarations completed and their template parameter scopes were popped.
This in turn caused us to be unable to merge class template declarations that
were declared in the global scope (where we use scope lookup rather than
DeclContext lookup for merging), when loading a module.
llvm-svn: 216311
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 63581a44dbe..fb05718ff1b 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -1105,9 +1105,13 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, AddPushedVisibilityAttribute(NewClass); - if (TUK != TUK_Friend) - PushOnScopeChains(NewTemplate, S); - else { + if (TUK != TUK_Friend) { + // Per C++ [basic.scope.temp]p2, skip the template parameter scopes. + Scope *Outer = S; + while ((Outer->getFlags() & Scope::TemplateParamScope) != 0) + Outer = Outer->getParent(); + PushOnScopeChains(NewTemplate, Outer); + } else { if (PrevClassTemplate && PrevClassTemplate->getAccess() != AS_none) { NewTemplate->setAccess(PrevClassTemplate->getAccess()); NewClass->setAccess(PrevClassTemplate->getAccess()); |