diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-07-08 23:07:34 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-07-08 23:07:34 +0000 |
commit | cddc69fc3fe17b043a287a41e3706766c3d09a79 (patch) | |
tree | d2d4db14b83a62da469ed5e29e5fee1810b7d045 /lib/Sema/Sema.cpp | |
parent | a93e3b5bde9f0a7b59215f19f176f7d69881b81c (diff) |
When looking for an entity's Scope, don't consider scopes that can't contain declarations. Fixes PR7594.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107927 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 6194c293d2..cddc84eeed 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -405,9 +405,12 @@ Scope *Sema::getScopeForContext(DeclContext *Ctx) { Ctx = Ctx->getPrimaryContext(); for (Scope *S = getCurScope(); S; S = S->getParent()) { - if (DeclContext *Entity = static_cast<DeclContext *> (S->getEntity())) - if (Ctx == Entity->getPrimaryContext()) - return S; + // Ignore scopes that cannot have declarations. This is important for + // out-of-line definitions of static class members. + if (S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope)) + if (DeclContext *Entity = static_cast<DeclContext *> (S->getEntity())) + if (Ctx == Entity->getPrimaryContext()) + return S; } return 0; |