Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion interpreter/cling/lib/Utils/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,15 @@ namespace utils {
// No definition, no lookup result.
return;
}
S->LookupQualifiedName(R, const_cast<DeclContext*>(primaryWithin));
bool res =
S->LookupQualifiedName(R, const_cast<DeclContext*>(primaryWithin));

// If the lookup fails and the context is a namespace, try to lookup in
// the namespaces by setting NotForRedeclaration.
if (!res && primaryWithin->isNamespace()) {
R.setRedeclarationKind(Sema::NotForRedeclaration);
S->LookupQualifiedName(R, const_cast<DeclContext*>(primaryWithin));
}
}
}

Expand Down
1 change: 1 addition & 0 deletions interpreter/cling/test/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DisableFormat: true
24 changes: 24 additions & 0 deletions interpreter/cling/test/Lookup/named.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ namespace AnotherNext {
class Inside_AnotherNext {};
}

namespace A {
class C;
}
namespace B {
using namespace A;
}

.rawInput 0

// ROOT-6095: names introduced in a scopeless enum should be available in the
Expand Down Expand Up @@ -106,3 +113,20 @@ decl
decl = utils::Lookup::Named(&S, "EvenLess", context);
decl
//CHECK: (const clang::NamedDecl *) {{0x0*$|nullptr}}

// Lookup the declaration for namespace B.
decl = utils::Lookup::Named(&S, "B", nullptr);
decl
// CHECK: (const clang::NamedDecl *) 0x{{[1-9a-f][0-9a-f]*$}}

const clang::DeclContext* contextB = llvm::dyn_cast<clang::DeclContext>(decl);
contextB
// CHECK: (const clang::DeclContext *) 0x{{[1-9a-f][0-9a-f]*$}}

// Lookup 'C' from namespace B.
decl = utils::Lookup::Named(&S, "C", contextB);
decl
// CHECK: (const clang::NamedDecl *) 0x{{[1-9a-f][0-9a-f]*$}}

decl->getQualifiedNameAsString()
// CHECK: (std::string) "A::C"