Re: [pph] Add preprocessor validation

2011-03-04 Thread Diego Novillo

On 03/04/2011 05:46 PM, Lawrence Crowl wrote:

Add preprocessor symbol verification to PPH.
Write the used symbol table instead of a dummy PPH file.
Reuse PTH code for verifying these symbols are correct.
Modify verification to allow a preprocessor symbol to match the PPH
file's after value as well as its before value.
Stop storing the macro name redundantly within its value.
Mark three tests as expected failures as a result.
There are 2 unexpected failures and 2 unexpected passes to be fixed.

Add three different PPH output formats,
the regular object file, the pretty printed form, and the full dump form.
These formats are more stubs than anything else.

Make pretty printing closer to compilable code.
Add new flag TDF_VISDEF to request display of visible definitions.
For now, they are most particularly struct definitions.
Turn off visible definitions for bases of arrays and pointers.



OK.


Diego.


[pph] Add preprocessor validation

2011-03-04 Thread Lawrence Crowl
Add preprocessor symbol verification to PPH.
   Write the used symbol table instead of a dummy PPH file.
   Reuse PTH code for verifying these symbols are correct.
   Modify verification to allow a preprocessor symbol to match the PPH
   file's after value as well as its before value.
   Stop storing the macro name redundantly within its value.
   Mark three tests as expected failures as a result.
   There are 2 unexpected failures and 2 unexpected passes to be fixed.

Add three different PPH output formats,
   the regular object file, the pretty printed form, and the full dump form.
   These formats are more stubs than anything else.

Make pretty printing closer to compilable code.
   Add new flag TDF_VISDEF to request display of visible definitions.
   For now, they are most particularly struct definitions.
   Turn off visible definitions for bases of arrays and pointers.

-- 
Lawrence Crowl


src.change
Description: Binary data
Index: gcc/tree-pretty-print.c
===
*** gcc/tree-pretty-print.c	(revision 170279)
--- gcc/tree-pretty-print.c	(working copy)
*** dump_generic_node (pretty_printer *buffe
*** 771,777 
  {
  	  unsigned int quals = TYPE_QUALS (node);
  
!   dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
  	  pp_space (buffer);
  	  pp_string (buffer, str);
  
--- 771,778 
  {
  	  unsigned int quals = TYPE_QUALS (node);
  
!   dump_generic_node (buffer, TREE_TYPE (node), spc,
! 			 flags & !TDF_VISDEF, false);
  	  pp_space (buffer);
  	  pp_string (buffer, str);
  
*** dump_generic_node (pretty_printer *buffe
*** 918,924 
  	for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
  	 tmp = TREE_TYPE (tmp))
  	  ;
! 	dump_generic_node (buffer, tmp, spc, flags, false);
  
  	/* Print the dimensions.  */
  	for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
--- 919,925 
  	for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
  	 tmp = TREE_TYPE (tmp))
  	  ;
! 	dump_generic_node (buffer, tmp, spc, flags & !TDF_VISDEF, false);
  
  	/* Print the dimensions.  */
  	for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
*** dump_generic_node (pretty_printer *buffe
*** 937,957 
  	if (quals & TYPE_QUAL_VOLATILE)
  	  pp_string (buffer, "volatile ");
  
! /* Print the name of the structure.  */
! if (TREE_CODE (node) == RECORD_TYPE)
! 	  pp_string (buffer, "struct ");
! else if (TREE_CODE (node) == UNION_TYPE)
! 	  pp_string (buffer, "union ");
! 
! if (TYPE_NAME (node))
! 	  dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
! 	else if (!(flags & TDF_SLIM))
! 	  /* FIXME: If we eliminate the 'else' above and attempt
! 	 to show the fields for named types, we may get stuck
! 	 following a cycle of pointers to structs.  The alleged
! 	 self-reference check in print_struct_decl will not detect
! 	 cycles involving more than one pointer or struct type.  */
  	  print_struct_decl (buffer, node, spc, flags);
  break;
}
  
--- 938,962 
  	if (quals & TYPE_QUAL_VOLATILE)
  	  pp_string (buffer, "volatile ");
  
! 	if (flags & TDF_VISDEF)
  	  print_struct_decl (buffer, node, spc, flags);
+ 	else
+ 	  {
+ 	/* Print the name of the structure.  */
+ 	if (TREE_CODE (node) == RECORD_TYPE)
+ 	  pp_string (buffer, "struct ");
+ 	else if (TREE_CODE (node) == UNION_TYPE)
+ 	  pp_string (buffer, "union ");
+ 	if (TYPE_NAME (node))
+ 	  dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
+ 	else if (!(flags & TDF_SLIM))
+ 	  /* FIXME: If we eliminate the 'else' above and attempt
+ 		 to show the fields for named types, we may get stuck
+ 		 following a cycle of pointers to structs.  The alleged
+ 		 self-reference check in print_struct_decl will not detect
+ 		 cycles involving more than one pointer or struct type.  */
+ 	  print_struct_decl (buffer, node, spc, flags);
+ 	  }
  break;
}
  
*** dump_generic_node (pretty_printer *buffe
*** 2308,2329 
return spc;
  }
  
! /* Print the declaration of a variable.  */
  
  void
  print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
  {
!   INDENT (spc);
  
!   if (TREE_CODE (t) == TYPE_DECL)
! pp_string (buffer, "typedef ");
  
if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
  pp_string (buffer, "register ");
  
if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
  pp_string (buffer, "extern ");
!   else if (TREE_STATIC (t))
  pp_string (buffer, "static ");
  
/* Print the type and name.  */
--- 2313,2341 
return spc;
  }
  
! /* Print a declaration.  */
  
  void
  print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
  {
!   /* When printing visible definitions, do not print artificial types,
!