diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-03 16:37:14 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-03 16:37:14 +0000 |
commit | fb35e8f497d180e562e2e1bd8cd4b756b2d4a846 (patch) | |
tree | 5e89f0d2e52c82efcd1db8a98cf74f0325a2ce7c /lib/Sema/SemaDeclCXX.cpp | |
parent | b4efaa0a14dd2382aa028c03283b5a7f5345e24d (diff) |
When we're checking a friend function template in an out-of-line class
definition, we may not have a scope corresponding to the namespace
where that friend function template actually lives. Work around this
issue by faking up a scope with the appropriate DeclContext.
This is a bit of a hack, but it fixes <rdar://problem/10204947>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143614 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 7a423a73f0..a4e25231a7 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -10050,7 +10050,7 @@ Decl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, diag::err_friend_is_member); DCScope = getScopeForDeclContext(S, DC); - + // C++ [class.friend]p6: // A function can be defined in a friend declaration of a class if and // only if the class is a non-local class (9.8), the function name is @@ -10142,6 +10142,15 @@ Decl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, } } + // FIXME: This is an egregious hack to cope with cases where the scope stack + // does not contain the declaration context, i.e., in an out-of-line + // definition of a class. + Scope FakeDCScope(S, Scope::DeclScope, Diags); + if (!DCScope) { + FakeDCScope.setEntity(DC); + DCScope = &FakeDCScope; + } + bool AddToScope = true; NamedDecl *ND = ActOnFunctionDeclarator(DCScope, D, DC, TInfo, Previous, move(TemplateParams), AddToScope); |