Early exit from cp_write_global_declarations in the PCH case completely
broke -fdump-translation-unit; the simple fix is just to do the dump on
the PCH path as well.
Tested x86_64-pc-linux-gnu, applying to trunk and 4.8.
commit 106091d492179afa32d3042c4c74fb2ae6c440f4
Author: Jason Merrill <ja...@redhat.com>
Date: Thu Sep 12 18:33:21 2013 -0400
PR c++/57850
* decl2.c (dump_tu): Split out from...
(cp_write_global_declarations): ...here. Call it in PCH mode.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 4ebc155..5e5f5e8 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4041,6 +4041,22 @@ handle_tls_init (void)
expand_or_defer_fn (finish_function (0));
}
+/* The entire file is now complete. If requested, dump everything
+ to a file. */
+
+static void
+dump_tu (void)
+{
+ int flags;
+ FILE *stream = dump_begin (TDI_tu, &flags);
+
+ if (stream)
+ {
+ dump_node (global_namespace, flags & ~TDF_SLIM, stream);
+ dump_end (TDI_tu, stream);
+ }
+}
+
/* This routine is called at the end of compilation.
Its job is to create all the code needed to initialize and
destroy the global aggregates. We do the destruction
@@ -4071,6 +4087,7 @@ cp_write_global_declarations (void)
if (pch_file)
{
c_common_write_pch ();
+ dump_tu ();
return;
}
@@ -4457,16 +4474,7 @@ cp_write_global_declarations (void)
/* The entire file is now complete. If requested, dump everything
to a file. */
- {
- int flags;
- FILE *stream = dump_begin (TDI_tu, &flags);
-
- if (stream)
- {
- dump_node (global_namespace, flags & ~TDF_SLIM, stream);
- dump_end (TDI_tu, stream);
- }
- }
+ dump_tu ();
if (flag_detailed_statistics)
{