Split C++ test x1funcstatic.cc into a C test and a C++ test. Stream out and in various C++ tree members.
Index: gcc/testsuite/ChangeLog.pph 2011-05-20 Lawrence Crowl <cr...@google.com> * x1funcstatic.h: Rename to c1funcstatic.h, as contents are C only. * x1funcstatic.c: Use c1funcstatic.h instead of x1funcstatic.h. * c1funcstatic.c: Add to test C functionality. Index: gcc/cp/ChangeLog.pph 2011-05-20 Lawrence Crowl <cr...@google.com> * pph-streamer-in.c (pph_stream_read_qual_use_vec): Add. (pph_stream_read_tree_vec_none): Add. (pph_stream_read_tree): Add read of various C++ fields. * pph-streamer-out.c (pph_stream_write_qual_use_vec): Add. (pph_stream_write_tree_vec_none): Add. (pph_stream_write_tree): Add write of various C++ fields. Index: gcc/testsuite/g++.dg/pph/c1funcstatic.cc =================================================================== --- gcc/testsuite/g++.dg/pph/c1funcstatic.cc (revision 0) +++ gcc/testsuite/g++.dg/pph/c1funcstatic.cc (revision 0) @@ -0,0 +1,2 @@ +#include "c1funcstatic.h" +int g() { return f(); } Index: gcc/testsuite/g++.dg/pph/c1funcstatic.h =================================================================== --- gcc/testsuite/g++.dg/pph/c1funcstatic.h (revision 0) +++ gcc/testsuite/g++.dg/pph/c1funcstatic.h (revision 0) @@ -0,0 +1,7 @@ +#ifndef C1FUNCSTATIC_H +#define C1FUNCSTATIC_H +static int f() { + static int x = 3; + return x++; +} +#endif Index: gcc/testsuite/g++.dg/pph/x1funcstatic.h =================================================================== --- gcc/testsuite/g++.dg/pph/x1funcstatic.h (revision 173763) +++ gcc/testsuite/g++.dg/pph/x1funcstatic.h (working copy) @@ -1,7 +0,0 @@ -#ifndef X1FUNCSTATIC_H -#define X1FUNCSTATIC_H -static int f() { - static int x = 3; - return x++; -} -#endif Index: gcc/testsuite/g++.dg/pph/x1funcstatic.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x1funcstatic.cc (revision 173763) +++ gcc/testsuite/g++.dg/pph/x1funcstatic.cc (working copy) @@ -1,2 +1,2 @@ -#include "x1funcstatic.h" +#include "c1funcstatic.h" int a = f(); Index: gcc/cp/pph-streamer-in.c =================================================================== --- gcc/cp/pph-streamer-in.c (revision 173763) +++ gcc/cp/pph-streamer-in.c (working copy) @@ -224,7 +224,7 @@ pph_stream_read_ld_min (pph_stream *stre } -/* Read and return a VEC of trees from STREAM. */ +/* Read and return a gc VEC of trees from STREAM. */ VEC(tree,gc) * pph_stream_read_tree_vec (pph_stream *stream) @@ -243,6 +243,46 @@ pph_stream_read_tree_vec (pph_stream *st return v; } + +/* Read and return a gc VEC of qualified_typedef_usage_t from STREAM. */ + +static VEC(qualified_typedef_usage_t,gc) * +pph_stream_read_qual_use_vec (pph_stream *stream) +{ + unsigned i, num; + VEC(qualified_typedef_usage_t,gc) *v; + + num = pph_input_uint (stream); + v = NULL; + for (i = 0; i < num; i++) + { + qualified_typedef_usage_t q; + q.typedef_decl = pph_input_tree (stream); + q.context = pph_input_tree (stream); + /* FIXME pph: also read location. */ + VEC_safe_push (qualified_typedef_usage_t, gc, v, &q); + } + + return v; +} + + +/* Read a trees from STREAM and write into a none VEC v. */ + +static VEC(tree,none) * +pph_stream_read_tree_vec_none (pph_stream *stream, VEC(tree,none) *v) +{ + unsigned i, num; + + num = pph_input_uint (stream); + VEC_embedded_init (tree, v, num); + for (i = 0; i < num; i++) + VEC_quick_push (tree, v, pph_input_tree (stream)); + + return v; +} + + /* Forward declaration to break cyclic dependencies. */ static struct cp_binding_level *pph_stream_read_binding_level (pph_stream *); @@ -784,6 +824,7 @@ pph_stream_read_tree (struct lto_input_b if (DECL_P (expr)) { DECL_INITIAL (expr) = pph_input_tree (stream); + /* FIXME pph: DECL_NAME (expr) = pph_input_tree (stream); */ if (TREE_CODE (expr) == FUNCTION_DECL || TREE_CODE (expr) == NAMESPACE_DECL @@ -817,4 +858,57 @@ pph_stream_read_tree (struct lto_input_b TYPE_BINFO (expr) = pph_input_tree (stream); } } + else if (TREE_CODE (expr) == OVERLOAD) + { + OVL_FUNCTION (expr) = pph_input_tree (stream); + } + else if (TREE_CODE (expr) == IDENTIFIER_NODE) + { + const char *str; + struct lang_identifier *id = LANG_IDENTIFIER_CAST(expr); + TREE_TYPE (expr) = pph_input_tree (stream); + str = pph_input_string (stream); + /* FIXME pph: There must be a better way. */ + IDENTIFIER_NODE_CHECK (expr)->identifier.id.str + = (const unsigned char *)str; + IDENTIFIER_LENGTH (expr) = strlen (str); + id->namespace_bindings = pph_stream_read_cxx_binding (stream); + id->bindings = pph_stream_read_cxx_binding (stream); + id->class_template_info = pph_input_tree (stream); + id->label_value = pph_input_tree (stream); + } + else if (TREE_CODE (expr) == BASELINK) + { + BASELINK_BINFO (expr) = pph_input_tree (stream); + BASELINK_FUNCTIONS (expr) = pph_input_tree (stream); + BASELINK_ACCESS_BINFO (expr) = pph_input_tree (stream); + } + else if (TREE_CODE (expr) == TREE_BINFO) + { + BINFO_OFFSET (expr) = pph_input_tree (stream); + BINFO_VTABLE (expr) = pph_input_tree (stream); + BINFO_VIRTUALS (expr) = pph_input_tree (stream); + BINFO_VPTR_FIELD (expr) = pph_input_tree (stream); + BINFO_BASE_ACCESSES (expr) = pph_stream_read_tree_vec (stream); + BINFO_INHERITANCE_CHAIN (expr) = pph_input_tree (stream); + BINFO_SUBVTT_INDEX (expr) = pph_input_tree (stream); + BINFO_VPTR_INDEX (expr) = pph_input_tree (stream); + pph_stream_read_tree_vec_none (stream, BINFO_BASE_BINFOS (expr) ); + } + else if (TREE_CODE (expr) == TEMPLATE_DECL) + { + DECL_TEMPLATE_RESULT (expr) = pph_input_tree (stream); + DECL_TEMPLATE_PARMS (expr) = pph_input_tree (stream); + DECL_CONTEXT (expr) = pph_input_tree (stream); + } + else if (TREE_CODE (expr) == TEMPLATE_INFO) + { + TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr) + = pph_stream_read_tree_vec (stream); + } + else if (TREE_CODE (expr) == TREE_LIST) + ; /* FIXME pph: already handled? */ + else if (flag_pph_debug >= 2) + fprintf (pph_logfile, "PPH: unimplemented read of %s\n", + tree_code_name[TREE_CODE (expr)]); } Index: gcc/cp/pph-streamer-out.c =================================================================== --- gcc/cp/pph-streamer-out.c (revision 173763) +++ gcc/cp/pph-streamer-out.c (working copy) @@ -262,8 +262,8 @@ pph_stream_write_ld_min (pph_stream *str } -/* Write all the trees in VEC V to STREAM. REF_P is true if the trees should - be written as references. */ +/* Write all the trees in gc VEC V to STREAM. REF_P is true if the + trees should be written as references. */ void pph_stream_write_tree_vec (pph_stream *stream, VEC(tree,gc) *v, bool ref_p) @@ -276,6 +276,43 @@ pph_stream_write_tree_vec (pph_stream *s pph_output_tree_or_ref (stream, t, ref_p); } + +/* Write all the qualified_typedef_usage_t in VEC V to STREAM. + REF_P is true if the trees should be written as references. */ + +static void +pph_stream_write_qual_use_vec (pph_stream *stream, + VEC(qualified_typedef_usage_t,gc) *v, bool ref_p) +{ + unsigned i; + qualified_typedef_usage_t *q; + + pph_output_uint (stream, VEC_length (qualified_typedef_usage_t, v)); + for (i = 0; VEC_iterate (qualified_typedef_usage_t, v, i, q); i++) + { + pph_output_tree_or_ref (stream, q->typedef_decl, ref_p); + pph_output_tree_or_ref (stream, q->context, ref_p); + /* FIXME pph: also write location? */ + } +} + + +/* Write all the trees in non VEC V to STREAM. REF_P is true if the + trees should be written as references. */ + +static void +pph_stream_write_tree_vec_none (pph_stream *stream, VEC(tree,none) *v, + bool ref_p) +{ + unsigned i; + tree t; + + pph_output_uint (stream, VEC_length (tree, v)); + for (i = 0; VEC_iterate (tree, v, i, t); i++) + pph_output_tree_or_ref (stream, t, ref_p); +} + + /* Forward declaration to break cyclic dependencies. */ static void pph_stream_write_binding_level (pph_stream *, struct cp_binding_level *, bool); @@ -788,6 +825,9 @@ pph_stream_write_tree (struct output_blo if (DECL_P (expr)) { pph_output_tree_or_ref_1 (stream, DECL_INITIAL (expr), ref_p, 3); + /* FIXME pph: + pph_output_tree_or_ref_1 (stream, DECL_NAME (expr), ref_p, 3); + */ if (TREE_CODE (expr) == FUNCTION_DECL || TREE_CODE (expr) == NAMESPACE_DECL @@ -828,6 +868,57 @@ pph_stream_write_tree (struct output_blo pph_output_tree_or_ref_1 (stream, TYPE_BINFO (expr), ref_p, 3); } } + else if (TREE_CODE (expr) == OVERLOAD) + { + pph_output_tree_or_ref_1 (stream, OVL_CURRENT (expr), ref_p, 3); + } + else if (TREE_CODE (expr) == IDENTIFIER_NODE) + { + struct lang_identifier *id = LANG_IDENTIFIER_CAST(expr); + pph_output_tree_or_ref_1 (stream, TREE_TYPE (expr), ref_p, 3); + pph_output_string_with_length (stream, IDENTIFIER_POINTER (expr), + IDENTIFIER_LENGTH (expr)); + pph_stream_write_cxx_binding (stream, id->namespace_bindings, ref_p); + pph_stream_write_cxx_binding (stream, id->bindings, ref_p); + pph_output_tree_or_ref_1 (stream, id->class_template_info, ref_p, 3); + pph_output_tree_or_ref_1 (stream, id->label_value, ref_p, 3); + } + else if (TREE_CODE (expr) == BASELINK) + { + pph_output_tree_or_ref_1 (stream, BASELINK_BINFO (expr), ref_p, 3); + pph_output_tree_or_ref_1 (stream, BASELINK_FUNCTIONS (expr), ref_p, 3); + pph_output_tree_or_ref_1 (stream, BASELINK_ACCESS_BINFO (expr), ref_p, 3); + } + else if (TREE_CODE (expr) == TREE_BINFO) + { + pph_output_tree_or_ref_1 (stream, BINFO_OFFSET (expr), ref_p, 3); + pph_output_tree_or_ref_1 (stream, BINFO_VTABLE (expr), ref_p, 3); + pph_output_tree_or_ref_1 (stream, BINFO_VIRTUALS (expr), ref_p, 3); + pph_output_tree_or_ref_1 (stream, BINFO_VPTR_FIELD (expr), ref_p, 3); + pph_stream_write_tree_vec (stream, BINFO_BASE_ACCESSES (expr), ref_p); + pph_output_tree_or_ref_1 (stream, BINFO_INHERITANCE_CHAIN (expr), + ref_p, 3); + pph_output_tree_or_ref_1 (stream, BINFO_SUBVTT_INDEX (expr), ref_p, 3); + pph_output_tree_or_ref_1 (stream, BINFO_VPTR_INDEX (expr), ref_p, 3); + pph_stream_write_tree_vec_none (stream, BINFO_BASE_BINFOS (expr), ref_p); + } + else if (TREE_CODE (expr) == TEMPLATE_DECL) + { + pph_output_tree_or_ref_1 (stream, DECL_TEMPLATE_RESULT (expr), ref_p, 3); + pph_output_tree_or_ref_1 (stream, DECL_TEMPLATE_PARMS (expr), ref_p, 3); + pph_output_tree_or_ref_1 (stream, DECL_CONTEXT (expr), ref_p, 3); + /* FIXME pph: what of bit DECL_MEMBER_TEMPLATE_P (expr) */ + } + else if (TREE_CODE (expr) == TEMPLATE_INFO) + { + pph_stream_write_qual_use_vec (stream, + TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr), ref_p); + } + else if (TREE_CODE (expr) == TREE_LIST) + ; /* FIXME pph: already handled? */ + else if (flag_pph_debug >= 2) + fprintf (pph_logfile, "PPH: unimplemented write of %s\n", + tree_code_name[TREE_CODE (expr)]); } -- This patch is available for review at http://codereview.appspot.com/4550064