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]
Other format: [Raw text]

[PATCH] use fileline typedef


This fixes three cpp* files to use the fileline typedef when
appropriate.  There are certainly more in other files.  (Once we
have fixed most of them, then I'd like to define fileline as a
struct type when ENABLE_CHECKING is selected, so we can catch
incorrect usage.)

I checked this into the trunk.  I had earlier (08-21) checked it
into the compiler server branch.

2003-08-26 Per Bothner <pbothner@apple.com>

	* cpplib.h (struct cpp_token):  Change type of field line to fileline.
	(cpp_error_with_line):  Use fileline for appropriate parameter.
	* cpphash.h (struct cpp_macro):  Change type of field line to fileline.
	(struct cpp_reader):  Likewise for fields line and directive_line.
	(_cpp_begin_message):  Use fileline for appropriate parameter.
	* cpperror.c (print_location, _cpp_begin_message, cpp_error_with_line,
	cpp_error):  Use fileline for appropriate parameters and variables.
	(print_location):  New local lin, since it is not a fileline.

--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index: cpperror.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpperror.c,v
retrieving revision 1.67
diff -u -p -r1.67 cpperror.c
--- cpperror.c	22 Jul 2003 16:24:53 -0000	1.67
+++ cpperror.c	25 Aug 2003 21:44:01 -0000
@@ -29,34 +29,35 @@ Foundation, 59 Temple Place - Suite 330,
 #include "cpphash.h"
 #include "intl.h"
 
-static void print_location (cpp_reader *, unsigned int, unsigned int);
+static void print_location (cpp_reader *, fileline, unsigned int);
 
 /* Print the logical file location (LINE, COL) in preparation for a
    diagnostic.  Outputs the #include chain if it has changed.  A line
    of zero suppresses the include stack, and outputs the program name
    instead.  */
 static void
-print_location (cpp_reader *pfile, unsigned int line, unsigned int col)
+print_location (cpp_reader *pfile, fileline line, unsigned int col)
 {
   if (!pfile->buffer || line == 0)
     fprintf (stderr, "%s: ", progname);
   else
     {
       const struct line_map *map;
+      unsigned int lin;
 
       map = linemap_lookup (&pfile->line_maps, line);
       linemap_print_containing_files (&pfile->line_maps, map);
 
-      line = SOURCE_LINE (map, line);
+      lin = SOURCE_LINE (map, line);
       if (col == 0)
 	col = 1;
 
-      if (line == 0)
+      if (lin == 0)
 	fprintf (stderr, "%s:", map->to_file);
       else if (CPP_OPTION (pfile, show_column) == 0)
-	fprintf (stderr, "%s:%u:", map->to_file, line);
+	fprintf (stderr, "%s:%u:", map->to_file, lin);
       else
-	fprintf (stderr, "%s:%u:%u:", map->to_file, line, col);
+	fprintf (stderr, "%s:%u:%u:", map->to_file, lin, col);
 
       fputc (' ', stderr);
     }
@@ -68,7 +69,7 @@ print_location (cpp_reader *pfile, unsig
    the correct place by default.  Returns 0 if the error has been
    suppressed.  */
 int
-_cpp_begin_message (cpp_reader *pfile, int code, unsigned int line,
+_cpp_begin_message (cpp_reader *pfile, int code, fileline line,
 		    unsigned int column)
 {
   int level = DL_EXTRACT (code);
@@ -124,7 +125,8 @@ _cpp_begin_message (cpp_reader *pfile, i
 void
 cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
 {
-  unsigned int line, column;
+  fileline line;
+  unsigned int column;
   va_list ap;
   
   va_start (ap, msgid);
@@ -157,7 +159,7 @@ cpp_error (cpp_reader * pfile, int level
 /* Print an error at a specific location.  */
 void
 cpp_error_with_line (cpp_reader *pfile, int level,
-		     unsigned int line, unsigned int column,
+		     fileline line, unsigned int column,
 		     const char *msgid, ...)
 {
   va_list ap;
Index: cpphash.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpphash.h,v
retrieving revision 1.197
diff -u -p -r1.197 cpphash.h
--- cpphash.h	2 Aug 2003 16:29:44 -0000	1.197
+++ cpphash.h	25 Aug 2003 21:44:02 -0000
@@ -100,7 +100,7 @@ struct cpp_macro
   } exp;
 
   /* Definition line number.  */
-  unsigned int line;
+  fileline line;
 
   /* Number of tokens in expansion, or bytes for traditional macros.  */
   unsigned int count;
@@ -337,10 +337,10 @@ struct cpp_reader
   /* Source line tracking.  */
   struct line_maps line_maps;
   const struct line_map *map;
-  unsigned int line;
+  fileline line;
 
   /* The line of the '#' of the current directive.  */
-  unsigned int directive_line;
+  fileline directive_line;
 
   /* Memory buffers.  */
   _cpp_buff *a_buff;		/* Aligned permanent storage.  */
@@ -497,7 +497,7 @@ extern unsigned char _cpp_trigraph_map[U
 #define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional)
 
 /* In cpperror.c  */
-extern int _cpp_begin_message (cpp_reader *, int, unsigned int, unsigned int);
+extern int _cpp_begin_message (cpp_reader *, int, fileline, unsigned int);
 
 /* In cppmacro.c */
 extern void _cpp_free_definition (cpp_hashnode *);
Index: cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.266
diff -u -p -r1.266 cpplib.h
--- cpplib.h	19 Aug 2003 21:04:38 -0000	1.266
+++ cpplib.h	25 Aug 2003 21:44:02 -0000
@@ -174,7 +174,7 @@ struct cpp_string
    occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts.  */
 struct cpp_token
 {
-  unsigned int line;		/* Logical line of first char of token.  */
+  fileline line;		/* Logical line of first char of token.  */
   unsigned short col;		/* Column of first char of token.  */
   ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT;  /* token type */
   unsigned char flags;		/* flags - see above */
@@ -680,8 +680,8 @@ extern void cpp_errno (cpp_reader *, int
 /* Same as cpp_error, except additionally specifies a position as a
    (translation unit) physical line and physical column.  If the line is
    zero, then no location is printed.  */
-extern void cpp_error_with_line (cpp_reader *, int, unsigned, unsigned, const char *msgid, ...)
-  ATTRIBUTE_PRINTF_5;
+extern void cpp_error_with_line (cpp_reader *, int, fileline, unsigned,
+				 const char *msgid, ...) ATTRIBUTE_PRINTF_5;
 
 /* In cpplex.c */
 extern int cpp_ideq (const cpp_token *, const char *);

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