If a name is injected into an imported inline namespace without reopening that

namespace, we need to update both the visible names of that namespace and of
its enclosing namespace set.

llvm-svn: 204570
This commit is contained in:
Richard Smith 2014-03-23 20:41:56 +00:00
parent 6756a497a1
commit e3a97029da
4 changed files with 21 additions and 3 deletions

View File

@ -184,10 +184,15 @@ void ASTDeclWriter::VisitDecl(Decl *D) {
// This happens when we instantiate a class with a friend declaration or a
// function with a local extern declaration, for instance.
if (D->isOutOfLine()) {
auto *NS = dyn_cast<NamespaceDecl>(D->getDeclContext()->getRedeclContext());
// FIXME: Also update surrounding inline namespaces.
if (NS && NS->isFromASTFile())
auto *DC = D->getDeclContext();
while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
if (!NS->isFromASTFile())
break;
Writer.AddUpdatedDeclContext(NS->getPrimaryContext());
if (!NS->isInlineNamespace())
break;
DC = NS->getParent();
}
}
}

View File

@ -9,3 +9,9 @@ namespace std {
typedef int size_t;
}
}
namespace X {
inline namespace Y {
struct Z;
}
}

View File

@ -198,6 +198,10 @@ module cxx_inline_namespace {
header "cxx-inline-namespace.h"
}
module cxx_inline_namespace_b {
header "cxx-inline-namespace-b.h"
}
module cxx_linkage_cache {
header "cxx-linkage-cache.h"
}

View File

@ -2,5 +2,8 @@
// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
@import cxx_inline_namespace;
@import cxx_inline_namespace_b;
T x; // expected-error {{unknown type name 'T'}}
X::Elaborated *p;