r172204 - in /branches/pph: gcc/cp/ChangeLog.pp...

crowl@gcc.gnu.org crowl@gcc.gnu.org
Fri Apr 8 18:42:00 GMT 2011


Author: crowl
Date: Fri Apr  8 18:42:55 2011
New Revision: 172204

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172204
Log:

In my last PPH change, I eliminated the redundancy in the preprocessor
identifier lookaside table by removing the name of the identifier from
the head of the macro value.  This later led to a buffer overrun in
libcpp/symtab.c cpp_lt_replay.  The buffer was allocated based on the
value string size, which is was no longer large enough to hold the
definition string.

Split cpp_idents_used.max_length and cpp_lookaside.max_length into
max_ident_len and max_value_len.  In cpp_lt_replay, allocate the
buffer based on the sum of max_ident_len and max_value_len.

The simple macro validation scheme for PTH is not sufficient for
PPH.  In particular, in libcpp, even identifiers that are skipped
in preprocessing are entered into the symbol table.  We need to
ignore these.  So, add two macro attributes, used_by_directive and
expanded_to_text.  If neither of these attributes is set, then the
macro is not used and can be ignored for validation and replay.

These changes bring the macro validation to a workable state.  There
may be some fine tuning later.

Make an inability to open a PPH file for reading a plain error rather
than a fatal error.  Fatal errors do not seem to play well with tests.

Adjust tests to reflect changes.  There is still one unexpected
failure, p1mean.cc does not compare equal in assembly.  Not yet
investigated.

Index: gcc/testsuite/ChangeLog.pph

2011-04-06  Lawrence Crowl  <crowl@google.com>

	* g++.dg/pph/p1mean.cc: Now pass validation.
	* g++.dg/pph/p1stdlib.cc: Likewise.
	* g++.dg/pph/d1symnotinc.cc: Failure to read is now not fatal.
        * g++.dg/pph/d1chained.cc: Miscategorized as a failure, ...
        * g++.dg/pph/c1chained.cc: so it has been renamed.

Index: gcc/cp/ChangeLog.pph

2011-04-06  Lawrence Crowl  <crowl@google.com>

        * pph.c (pth_dump_identifiers):  Split cpp_idents_used::max_length
	into max_ident_length and max_value_length.  Print used_by_directive
	and expanded_to_text attributes of macros.
	(pth_save_identifiers): Split cpp_idents_used::max_length into
	max_ident_length and max_value_length.  Filter out macro that are
	neither used_by_directive nor expanded_to_text, which requires
	precounting the number of entries remaining.  Save used_by_directive
	and expanded_to_text attributes of the macros.
	(pth_load_identifiers): Split cpp_idents_used::max_length into
	max_ident_length and max_value_length.  Restore used_by_directive and
	expanded_to_text attributes of the macros.
	(pph_read_file): Make failure to read a pph file a non-fatal error.

Index: libcpp/ChangeLog.pph

2011-04-06  Lawrence Crowl <crowl@google.com>

        * include/cpplib.h (struct cpp_hashnode): Add used_by_directive and
	expanded_to_text attributes for macros.  Take their bits from
	directive_index, which does not need them.
        * include/symtab.h (struct cpp_idents_used): Split max_length into
	max_ident_len and max_value_len.  Reorder fields to avoid gaps.
	(struct cpp_ident_use): Add used_by_directive and expanded_to_text
	attributes for macros.
        * internal.h (struct cpp_lookaside): Split max_length into
        max_ident_len and max_value_len.
	* macro.c (enter_macro_context): Mark expanded_to_text macro attribute.
	* directives.c (DIRECTIVE_TABLE): Add sizing comment.
	(do_define): Mark used_by_directive macro attribute.
	(do_undef): Likewise.
	(do_ifdef): Likewise.
	* expr.c (parse_defined): Mark used_by_directive macro attribute.
        * symtab.c (cpp_lt_create): Split cpp_lookaside::max_length into
	max_ident_len and max_value_len.
	* (lt_macro_value): Likewise.
	* (lt_lookup): Likewise.
        * (cpp_lt_capture): Likewise.  Also save used_by_directive and
	expanded_to_text attributes of macros.
        * (cpp_lt_replay): Split cpp_idents_used::max_lenth into
        max_ident_len and max_value_len.  Allocate a buffer with the sum.



Added:
    branches/pph/gcc/testsuite/g++.dg/pph/c1chained.cc
Removed:
    branches/pph/gcc/testsuite/g++.dg/pph/d1chained.cc
Modified:
    branches/pph/gcc/cp/ChangeLog.pph
    branches/pph/gcc/cp/pph.c
    branches/pph/gcc/testsuite/ChangeLog.pph
    branches/pph/gcc/testsuite/g++.dg/pph/d1symnotinc.cc
    branches/pph/gcc/testsuite/g++.dg/pph/p1mean.cc
    branches/pph/gcc/testsuite/g++.dg/pph/p1stdlib.cc
    branches/pph/libcpp/ChangeLog.pph
    branches/pph/libcpp/directives.c
    branches/pph/libcpp/expr.c
    branches/pph/libcpp/include/cpplib.h
    branches/pph/libcpp/include/symtab.h
    branches/pph/libcpp/internal.h
    branches/pph/libcpp/macro.c
    branches/pph/libcpp/symtab.c



More information about the Gcc-cvs mailing list