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 | caef9ab03c7a5fa06aeedd22cd0ddd8bd2c09990 (patch) | |
| tree | b501c30731a73d7692d4ff1d307bc224d1cda930 /clang/lib/Sema/Sema.cpp | |
| parent | 823e90e12a77d070fd672b8a2616f9f6f33117de (diff) | |
| download | bcm5719-llvm-caef9ab03c7a5fa06aeedd22cd0ddd8bd2c09990.tar.gz bcm5719-llvm-caef9ab03c7a5fa06aeedd22cd0ddd8bd2c09990.zip | |
When looking for an entity's Scope, don't consider scopes that can't contain declarations. Fixes PR7594.
llvm-svn: 107927
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 6194c293d2b..cddc84eeedf 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/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; |

