The fix of streaming DECL_CHAIN in pph for VAR_DECL and FUNCTION_DECL was 
introduced to fix "member not found" errors for structs (and we don't have any 
tests with unions (we probably should...), but I believe they work the same). 
The fix was too general and was actually interfering with something I'm trying 
to do as part of the bug fix I'm on.

This thus restricts the streaming of the DECL_CHAIN for those two types only 
when needed.

Again, this doesn't fix any tests, but helps me in the current bug I'm working 
on.

Tested with bootstrap and pph regression testing.

Gab

2011-07-08  Gabriel Charette  <gch...@google.com>

        * pph-streamer-in.c (pph_in_function_decl): Stream in
        DECL_CHAIN of FUNCTION_DECL only if it's part of a RECORD_OR_UNION_TYPE
        (pph_read_tree): Stream in DECL_CHAIN of VAR_DECL only if it's part
        of a RECORD_OR_UNION_TYPE.
        * pph-streamer-out.c (pph_out_function_decl): Stream out
        DECL_CHAIN of FUNCTION_DECL only if it's part of a RECORD_OR_UNION_TYPE
        (pph_write_tree): Stream out DECL_CHAIN of VAR_DECL only if it's part
        of a RECORD_OR_UNION_TYPE.

diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index 0bab93b..d78ee91 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -1396,7 +1396,8 @@ pph_in_function_decl (pph_stream *stream, tree fndecl)
   pph_in_lang_specific (stream, fndecl);
   DECL_SAVED_TREE (fndecl) = pph_in_tree (stream);
   DECL_STRUCT_FUNCTION (fndecl) = pph_in_struct_function (stream, fndecl);
-  DECL_CHAIN (fndecl) = pph_in_tree (stream);
+  if (DECL_CONTEXT (fndecl) && RECORD_OR_UNION_TYPE_P (DECL_CONTEXT (fndecl)))
+    DECL_CHAIN (fndecl) = pph_in_tree (stream);
   if (DECL_SAVED_TREE (fndecl))
     VEC_safe_push (tree, gc, stream->fns_to_expand, fndecl);
 }
@@ -1436,7 +1437,9 @@ pph_read_tree (struct lto_input_block *ib 
ATTRIBUTE_UNUSED,
       DECL_INITIAL (expr) = pph_in_tree (stream);
       pph_in_lang_specific (stream, expr);
       /* DECL_CHAIN is handled by generic code, except for VAR_DECLs.  */
-      if (TREE_CODE (expr) == VAR_DECL)
+      if (TREE_CODE (expr) == VAR_DECL
+         && DECL_CONTEXT (expr)
+         && RECORD_OR_UNION_TYPE_P (DECL_CONTEXT (expr)))
        DECL_CHAIN (expr) = pph_in_tree (stream);
       break;
 
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index 089bb13..d1e757f 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -1257,7 +1257,8 @@ pph_out_function_decl (pph_stream *stream, tree fndecl, 
bool ref_p)
   pph_out_lang_specific (stream, fndecl, ref_p);
   pph_out_tree_or_ref_1 (stream, DECL_SAVED_TREE (fndecl), ref_p, 3);
   pph_out_struct_function (stream, DECL_STRUCT_FUNCTION (fndecl), ref_p);
-  pph_out_tree_or_ref_1 (stream, DECL_CHAIN (fndecl), ref_p, 3);
+  if (DECL_CONTEXT (fndecl) && RECORD_OR_UNION_TYPE_P (DECL_CONTEXT (fndecl)))
+    pph_out_tree_or_ref_1 (stream, DECL_CHAIN (fndecl), ref_p, 3);
 }
 
 /* Callback for writing ASTs to a stream.  This writes all the fields
@@ -1292,7 +1293,9 @@ pph_write_tree (struct output_block *ob, tree expr, bool 
ref_p)
       pph_out_tree_or_ref_1 (stream, DECL_INITIAL (expr), ref_p, 3);
       pph_out_lang_specific (stream, expr, ref_p);
       /* DECL_CHAIN is handled by generic code, except for VAR_DECLs.  */
-      if (TREE_CODE (expr) == VAR_DECL)
+      if (TREE_CODE (expr) == VAR_DECL
+         && DECL_CONTEXT (expr)
+         && RECORD_OR_UNION_TYPE_P (DECL_CONTEXT (expr)))
        pph_out_tree_or_ref_1 (stream, DECL_CHAIN (expr), ref_p, 3);
       break;
 

--
This patch is available for review at http://codereview.appspot.com/4672055

Reply via email to