diff options
-rw-r--r-- | include/clang/AST/Decl.h | 3 | ||||
-rw-r--r-- | lib/Frontend/PCHReaderDecl.cpp | 8 | ||||
-rw-r--r-- | test/PCH/cxx-namespaces.cpp | 10 | ||||
-rw-r--r-- | test/PCH/cxx-namespaces.h | 7 |
4 files changed, 22 insertions, 6 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index da7ad1d217..c35a399263 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -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 diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index 8e0d635508..9de002b0e6 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -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++]))); } diff --git a/test/PCH/cxx-namespaces.cpp b/test/PCH/cxx-namespaces.cpp new file mode 100644 index 0000000000..0fd3de7f6c --- /dev/null +++ b/test/PCH/cxx-namespaces.cpp @@ -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; +} diff --git a/test/PCH/cxx-namespaces.h b/test/PCH/cxx-namespaces.h new file mode 100644 index 0000000000..f3389533d0 --- /dev/null +++ b/test/PCH/cxx-namespaces.h @@ -0,0 +1,7 @@ +// Header for PCH test cxx-namespaces.cpp + +namespace N { + namespace { + int x; + } +} |