summaryrefslogtreecommitdiffstats
path: root/clang/test/PCH/chain-staticvar-instantiation.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-07-02 19:19:01 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-07-02 19:19:01 +0000
commit442dd80715f71bd8118dc44b521f0e0bb35a697d (patch)
treea5f9804d604bf307bff1f11f2051195aa0605266 /clang/test/PCH/chain-staticvar-instantiation.cpp
parent200f47c65da5960b507437dc3f19bcc3aa0dd7b8 (diff)
downloadbcm5719-llvm-442dd80715f71bd8118dc44b521f0e0bb35a697d.tar.gz
bcm5719-llvm-442dd80715f71bd8118dc44b521f0e0bb35a697d.zip
[PCH] Make sure that all newly introduced visible decls in a DeclContext
coming from an AST file are registered for serialization. A static data member instantiation of in a chained PCH could be missed when serializing decls; the result was that when emitting the visible decls map of its DeclContext, we would use a DeclID that was not actually emitted, leading to crashes or hangs. Fix this by making sure such decls are always registered for serialization. Also introduce extra sanity checks to make sure we don't register new declarations or types after we have serialized the types/decls block. rdar://11728990 llvm-svn: 159550
Diffstat (limited to 'clang/test/PCH/chain-staticvar-instantiation.cpp')
-rw-r--r--clang/test/PCH/chain-staticvar-instantiation.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/clang/test/PCH/chain-staticvar-instantiation.cpp b/clang/test/PCH/chain-staticvar-instantiation.cpp
new file mode 100644
index 00000000000..0ab093f18d6
--- /dev/null
+++ b/clang/test/PCH/chain-staticvar-instantiation.cpp
@@ -0,0 +1,44 @@
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
+
+#ifndef HEADER1
+#define HEADER1
+//===----------------------------------------------------------------------===//
+
+namespace NS {
+
+template <class _Tp, _Tp __v>
+struct TS
+{
+ static const _Tp value = __v;
+};
+
+template <class _Tp, _Tp __v>
+const _Tp TS<_Tp, __v>::value;
+
+TS<int, 2> g1;
+
+}
+
+//===----------------------------------------------------------------------===//
+#elif not defined(HEADER2)
+#define HEADER2
+#if !defined(HEADER1)
+#error Header inclusion order messed up
+#endif
+
+int g2 = NS::TS<int, 2>::value;
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+#warning reached main file // expected-warning {{reached main file}}
+
+int g3 = NS::TS<int, 2>::value;
+
+//===----------------------------------------------------------------------===//
+#endif
OpenPOWER on IntegriCloud