This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch to c-lang.c: Initialize lang_printer



This patchlet defines lang_printer for the C front-end.  Its effect is
not yet observable.

Bootstrapped and tested on i686-pc-linux.  Installed.

-- Gaby
CodeSourcery, LLC		http://www.codesourcery.com

2000-08-20  Gabriel Dos Reis  <gdr@codesourcery.com>

	* c-lang.c: #include diagnostic.h
	(c_tree_printer): New function.
	(lang_init): Initialize lang_printer.

	* Makefile.in (c-lang.o): Depends on diagnostic.h

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.494
diff -p -r1.494 Makefile.in
*** Makefile.in	2000/08/05 00:50:00	1.494
--- Makefile.in	2000/08/20 14:54:01
*************** c-decl.o : c-decl.c $(CONFIG_H) system.h
*** 1102,1108 ****
  c-typeck.o : c-typeck.c $(CONFIG_H) system.h $(TREE_H) c-tree.h c-common.h \
      flags.h intl.h output.h $(EXPR_H) $(RTL_H) toplev.h
  c-lang.o : c-lang.c $(CONFIG_H) system.h $(TREE_H) c-tree.h c-common.h \
!     $(GGC_H)  c-lex.h toplev.h output.h function.h
  c-lex.o : c-lex.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) c-lex.h c-tree.h \
      c-common.h $(srcdir)/c-parse.h $(srcdir)/c-gperf.h c-pragma.h input.h \
      intl.h flags.h toplev.h output.h mbchar.h $(GGC_H)
--- 1102,1108 ----
  c-typeck.o : c-typeck.c $(CONFIG_H) system.h $(TREE_H) c-tree.h c-common.h \
      flags.h intl.h output.h $(EXPR_H) $(RTL_H) toplev.h
  c-lang.o : c-lang.c $(CONFIG_H) system.h $(TREE_H) c-tree.h c-common.h \
!     $(GGC_H)  c-lex.h toplev.h diagnostic.h output.h function.h
  c-lex.o : c-lex.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) c-lex.h c-tree.h \
      c-common.h $(srcdir)/c-parse.h $(srcdir)/c-gperf.h c-pragma.h input.h \
      intl.h flags.h toplev.h output.h mbchar.h $(GGC_H)
Index: c-lang.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lang.c,v
retrieving revision 1.30
diff -p -r1.30 c-lang.c
*** c-lang.c	2000/08/04 01:30:04	1.30
--- c-lang.c	2000/08/20 14:54:01
*************** Boston, MA 02111-1307, USA.  */
*** 28,37 ****
--- 28,40 ----
  #include "c-tree.h"
  #include "c-lex.h"
  #include "toplev.h"
+ #include "diagnostic.h"
  #include "output.h"
  #include "flags.h"
  #include "ggc.h"
  
+ static int c_tree_printer PARAMS ((output_buffer *));
+ 
  #if USE_CPPLIB
  #include "cpplib.h"
  extern char *yy_cur;
*************** lang_init ()
*** 92,97 ****
--- 95,102 ----
    restore_lang_status = &pop_c_function_context;
    mark_lang_status = &mark_c_function_context;
  
+   lang_printer = c_tree_printer;
+ 
    c_parse_init ();
  }
  
*************** finish_file ()
*** 239,242 ****
--- 244,282 ----
        assemble_destructor (IDENTIFIER_POINTER (fnname));
      }
  #endif
+ }
+ 
+ /* Called during diagnostic message formatting process to print a
+    source-level entity onto BUFFER.  The meaning of the format specifiers
+    is as follows:
+    %D: a general decl,
+    %F: a function declaration,
+    %T: a type.
+ 
+    These format specifiers form a subset of the format specifiers set used
+    by the C++ front-end.
+    Please notice when called, the `%' part was already skipped by the
+    diagnostic machinery.  */
+ static int
+ c_tree_printer (buffer)
+      output_buffer *buffer;
+ {
+   tree t = va_arg (output_buffer_format_args (buffer), tree);
+ 
+   switch (*output_buffer_text_cursor (buffer))
+     {
+     case 'D':
+     case 'F':
+     case 'T':
+       {
+         const char *n = DECL_NAME (t)
+           ? (*decl_printable_name) (t, 2)
+           : "({anonymous})";
+         output_add_string (buffer, n);
+       }
+       return 1;
+ 
+     default:
+       return 0;
+     }
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]