summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-07-08 23:07:34 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-07-08 23:07:34 +0000
commitcaef9ab03c7a5fa06aeedd22cd0ddd8bd2c09990 (patch)
treeb501c30731a73d7692d4ff1d307bc224d1cda930 /clang/lib/Sema/Sema.cpp
parent823e90e12a77d070fd672b8a2616f9f6f33117de (diff)
downloadbcm5719-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.cpp9
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;
OpenPOWER on IntegriCloud