Commit Message

This patch fixes a problem with streaming of symbols and types that
have mutated from one PPH to another.
--- parent.h -----------------------------------------------------------------
#include "child.h"
struct C1 {
int field1;
float field2;
};
-----------------------------------------------------------------------------
--- child.h -----------------------------------------------------------------
struct C1;
-----------------------------------------------------------------------------
When we read child.pph from parent.pph, we will notice that struct C1
has mutated, so we read its body again (which fills in the fields,
etc). However, the TYPE_LANG_DECL structure for C1 is also present in
the pickle cache for child.pph, and we were using it unmodified.
In this case, one of the fields in TYPE_LANG_DECL was
CLASSTYPE_LAZY_DEFAULT_CTOR, which had not been set in child.pph, so
when we tried to use the default ctor from struct C1 during code
generation, we were never finding it. This was causing the failure in
x1namespace-alias2.cc and two other ICEs in the dynarray tests.
What the patch does is to never insert in the pickle cache any
structures that are embedded in structures that are already inside
other structures that get put in the cache. We now always write out
the contents of these structures (using the PPH_RECORD_START_NO_CACHE
marker). This includes the structures: PPH_binding_table,
PPH_function, PPH_lang_decl, PPH_lang_type, PPH_language_function and
PPH_sorted_fields_type.
Since these structures are always embedded in structures that are
already shared, they are never read and allocated more than once,
unless the parent structure is pickled.
Additionally, this simplifies the logic in the reader, since it never
needs to worry about adding these structures to the cache.
cp/ChangeLog.pph
* name-lookup.c (pph_out_binding_table): Use
PPH_RECORD_START_NO_CACHE records.
(pph_in_binding_table): Likewise.
* pph-in.c (pph_in_language_function): Remove caching code,
assume that the structure is always in a
PPH_RECORD_START_NO_CACHE.
(pph_in_struct_function): Likewise.
(pph_in_lang_decl): Likewise.
(pph_in_sorted_fields_type): Likewise.
(pph_in_lang_type_class): Likewise.
(pph_in_lang_type): Likewise.
(pph_in_lang_decl_start): Remove.
* pph-out.c (pph_get_marker_for): Always return
PPH_RECORD_START_NO_CACHE for PPH_binding_table, PPH_function,
PPH_lang_decl, PPH_lang_type, PPH_language_function and
PPH_sorted_fields_type.
(pph_out_start_record): Do not write IX for
PPH_RECORD_START_NO_CACHE.
(pph_out_language_function): Only support
PPH_RECORD_START_NO_CACHE or PPH_RECORD_END.
(pph_out_struct_function): Likewise.
(pph_out_lang_decl): Likewise.
(pph_out_sorted_fields_type): Likewise.
(pph_out_lang_type_class): Likewise.
(pph_out_lang_type): Likewise.
testsuite/ChangeLog.pph
* g++.dg/pph/x1namespace-alias2.cc: Mark fixed.
* g++.dg/pph/x6dynarray4.cc: Remove expected ICE.
* g++.dg/pph/x7dynarray5.cc: Remove expected ICE.
--
This patch is available for review at http://codereview.appspot.com/5607045