aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2014-12-04 21:23:57 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2014-12-04 21:23:57 +0000
commitc8a15f362a905e13b382c027b959ea1114a645b4 (patch)
tree861faf8e8499fd13d98a465e9c7db178fb34dbbc /gcc
parent953971cf7dd11ab68caec04cae767f5dde656b23 (diff)
downloadgcc-c8a15f362a905e13b382c027b959ea1114a645b4.zip
gcc-c8a15f362a905e13b382c027b959ea1114a645b4.tar.gz
gcc-c8a15f362a905e13b382c027b959ea1114a645b4.tar.bz2
PR jit/63854: Fix double-initialization within tree-pretty-print.c
gcc/ChangeLog: PR jit/63854 * tree-pretty-print.c: Eliminate include of <new>. (buffer): Convert this variable from a pretty_printer to a pretty_printer *. (initialized): Eliminate this variable in favor of the NULL-ness of "buffer". (print_generic_decl): Update for "buffer" becoming a pointer. (print_generic_stmt): Likewise. (print_generic_stmt_indented): Likewise. (print_generic_expr): Likewise. (maybe_init_pretty_print): Likewise, allocating "buffer" on the heap and using its non-NULL-ness to ensure idempotency. From-SVN: r218404
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/tree-pretty-print.c34
2 files changed, 30 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3efe39e..92a46ed 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,21 @@
2014-12-04 David Malcolm <dmalcolm@redhat.com>
PR jit/63854
+ * tree-pretty-print.c: Eliminate include of <new>.
+ (buffer): Convert this variable from a pretty_printer to a
+ pretty_printer *.
+ (initialized): Eliminate this variable in favor of the NULL-ness
+ of "buffer".
+ (print_generic_decl): Update for "buffer" becoming a pointer.
+ (print_generic_stmt): Likewise.
+ (print_generic_stmt_indented): Likewise.
+ (print_generic_expr): Likewise.
+ (maybe_init_pretty_print): Likewise, allocating "buffer" on the
+ heap and using its non-NULL-ness to ensure idempotency.
+
+2014-12-04 David Malcolm <dmalcolm@redhat.com>
+
+ PR jit/63854
* ipa-prop.c (ipa_register_cgraph_hooks): Guard insertion of
ipa_add_new_function on function_insertion_hook_holder being
non-NULL.
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index df72abb..4117472 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -48,8 +48,6 @@ along with GCC; see the file COPYING3. If not see
#include "wide-int-print.h"
#include "internal-fn.h"
-#include <new> // For placement-new.
-
/* Local functions, macros and variables. */
static const char *op_symbol (const_tree);
static void pretty_print_string (pretty_printer *, const char*);
@@ -63,8 +61,7 @@ static void do_niy (pretty_printer *, const_tree);
#define NIY do_niy (buffer, node)
-static pretty_printer buffer;
-static int initialized = 0;
+static pretty_printer *buffer;
/* Try to print something for an unknown tree code. */
@@ -135,8 +132,8 @@ void
print_generic_decl (FILE *file, tree decl, int flags)
{
maybe_init_pretty_print (file);
- print_declaration (&buffer, decl, 2, flags);
- pp_write_text_to_stream (&buffer);
+ print_declaration (buffer, decl, 2, flags);
+ pp_write_text_to_stream (buffer);
}
/* Print tree T, and its successors, on file FILE. FLAGS specifies details
@@ -146,8 +143,8 @@ void
print_generic_stmt (FILE *file, tree t, int flags)
{
maybe_init_pretty_print (file);
- dump_generic_node (&buffer, t, 0, flags, true);
- pp_newline_and_flush (&buffer);
+ dump_generic_node (buffer, t, 0, flags, true);
+ pp_newline_and_flush (buffer);
}
/* Print tree T, and its successors, on file FILE. FLAGS specifies details
@@ -162,9 +159,9 @@ print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
maybe_init_pretty_print (file);
for (i = 0; i < indent; i++)
- pp_space (&buffer);
- dump_generic_node (&buffer, t, indent, flags, true);
- pp_newline_and_flush (&buffer);
+ pp_space (buffer);
+ dump_generic_node (buffer, t, indent, flags, true);
+ pp_newline_and_flush (buffer);
}
/* Print a single expression T on file FILE. FLAGS specifies details to show
@@ -174,8 +171,8 @@ void
print_generic_expr (FILE *file, tree t, int flags)
{
maybe_init_pretty_print (file);
- dump_generic_node (&buffer, t, 0, flags, false);
- pp_flush (&buffer);
+ dump_generic_node (buffer, t, 0, flags, false);
+ pp_flush (buffer);
}
/* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
@@ -3400,15 +3397,14 @@ pretty_print_string (pretty_printer *buffer, const char *str)
static void
maybe_init_pretty_print (FILE *file)
{
- if (!initialized)
+ if (!buffer)
{
- new (&buffer) pretty_printer ();
- pp_needs_newline (&buffer) = true;
- pp_translate_identifiers (&buffer) = false;
- initialized = 1;
+ buffer = new pretty_printer ();
+ pp_needs_newline (buffer) = true;
+ pp_translate_identifiers (buffer) = false;
}
- buffer.buffer->stream = file;
+ buffer->buffer->stream = file;
}
static void