forked from OSchip/llvm-project
When performing unqualified name lookup in C++, don't look directly
into transparent contexts; instead, we'll look into their nearest enclosing non-transparent contexts further up the stack. Fixes PR5479. llvm-svn: 90859
This commit is contained in:
parent
24c0bb1ca1
commit
a64c1e5452
|
@ -480,7 +480,12 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) {
|
|||
DeclContext *OuterCtx = findOuterContext(S);
|
||||
for (; Ctx && Ctx->getPrimaryContext() != OuterCtx;
|
||||
Ctx = Ctx->getLookupParent()) {
|
||||
if (Ctx->isFunctionOrMethod())
|
||||
// We do not directly look into function or method contexts
|
||||
// (since all local variables are found via the identifier
|
||||
// changes) or in transparent contexts (since those entities
|
||||
// will be found in the nearest enclosing non-transparent
|
||||
// context).
|
||||
if (Ctx->isFunctionOrMethod() || Ctx->isTransparentContext())
|
||||
continue;
|
||||
|
||||
// Perform qualified name lookup into this context.
|
||||
|
|
|
@ -40,3 +40,17 @@ namespace pr5430 {
|
|||
}
|
||||
using namespace pr5430;
|
||||
extern "C" void pr5430::func(void) { }
|
||||
|
||||
// PR5404
|
||||
int f2(char *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
int f2(int)
|
||||
{
|
||||
return f2((char *)0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,3 +112,12 @@ using namespace Alias;
|
|||
void testAlias() {
|
||||
inAliased();
|
||||
}
|
||||
|
||||
namespace N { void f2(int); }
|
||||
|
||||
extern "C++" {
|
||||
using namespace N;
|
||||
void f3() { f2(1); }
|
||||
}
|
||||
|
||||
void f4() { f2(1); }
|
||||
|
|
Loading…
Reference in New Issue