зеркало из https://github.com/microsoft/clang-1.git
When setting the anonymous namespace at PCH reading, it may still be initializing so avoid
the invariant checks at NamespaceDecl::setAnonymousNamespace(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107566 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
1139da148e
Коммит
a038c1dcfa
|
@ -344,6 +344,9 @@ public:
|
|||
static NamespaceDecl *castFromDeclContext(const DeclContext *DC) {
|
||||
return static_cast<NamespaceDecl *>(const_cast<DeclContext*>(DC));
|
||||
}
|
||||
|
||||
friend class PCHDeclReader;
|
||||
friend class PCHDeclWriter;
|
||||
};
|
||||
|
||||
/// ValueDecl - Represent the declaration of a variable (in which case it is
|
||||
|
|
|
@ -564,13 +564,9 @@ void PCHDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
|
|||
D->setNextNamespace(
|
||||
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
|
||||
// Only read one reference--the original or anonymous namespace.
|
||||
bool IsOriginal = Record[Idx++];
|
||||
if (IsOriginal)
|
||||
D->setAnonymousNamespace(
|
||||
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
else
|
||||
D->setOriginalNamespace(
|
||||
D->OrigOrAnonNamespace.setInt(IsOriginal);
|
||||
D->OrigOrAnonNamespace.setPointer(
|
||||
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// Test this without pch.
|
||||
// RUN: %clang_cc1 -include %S/cxx-namespaces.h -fsyntax-only -verify %s
|
||||
|
||||
// Test with pch.
|
||||
// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-namespaces.h
|
||||
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
|
||||
|
||||
void m() {
|
||||
N::x = 0;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// Header for PCH test cxx-namespaces.cpp
|
||||
|
||||
namespace N {
|
||||
namespace {
|
||||
int x;
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче