forked from OSchip/llvm-project
When looking for an entity's Scope, don't consider scopes that can't contain declarations. Fixes PR7594.
llvm-svn: 107927
This commit is contained in:
parent
823e90e12a
commit
caef9ab03c
|
@ -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;
|
||||
|
|
|
@ -39,3 +39,14 @@ namespace PR6570 {
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
namespace PR7594 {
|
||||
// If the lazy declaration of special member functions is triggered
|
||||
// in an out-of-line initializer, make sure the functions aren't in
|
||||
// the initializer scope. This used to crash Clang:
|
||||
struct C {
|
||||
C();
|
||||
static C *c;
|
||||
};
|
||||
C *C::c = new C();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue