Commit 8bbbef34 by Neil Booth Committed by Neil Booth

cpphash.h (struct cpp_reader): New member directive_line.

	* cpphash.h (struct cpp_reader): New member directive_line.
	* cpplib.h (struct cpp_callbacks): Update prototypes of callbacks.
	* cpplib.c (do_define, do_undef, do_ident, do_include_common,
	do_pragma): Pass line to callbacks.
	(start_directive): Record line of directive.
	* cppmain.c (cb_ident, cb_define, cb_undef, cb_def_pragma,
	cb_include): Similarly.
	* c-lex.c (cb_ident, cb_define, cb_undef, cb_def_pragma):
	Similarly.

From-SVN: r44637
parent 95146dd6
2001-08-04 Neil Booth <neil@daikokuya.demon.co.uk>
* cpphash.h (struct cpp_reader): New member directive_line.
* cpplib.h (struct cpp_callbacks): Update prototypes of callbacks.
* cpplib.c (do_define, do_undef, do_ident, do_include_common,
do_pragma): Pass line to callbacks.
(start_directive): Record line of directive.
* cppmain.c (cb_ident, cb_define, cb_undef, cb_def_pragma,
cb_include): Similarly.
* c-lex.c (cb_ident, cb_define, cb_undef, cb_def_pragma):
Similarly.
2001-08-04 Hans-Peter Nilsson <hp@bitrange.com> 2001-08-04 Hans-Peter Nilsson <hp@bitrange.com>
* config/d30v/d30v.h: Fix typo in start of UNIQUE_SECTION * config/d30v/d30v.h: Fix typo in start of UNIQUE_SECTION
......
...@@ -86,11 +86,14 @@ static tree lex_string PARAMS ((const char *, unsigned int, int)); ...@@ -86,11 +86,14 @@ static tree lex_string PARAMS ((const char *, unsigned int, int));
static tree lex_charconst PARAMS ((const cpp_token *)); static tree lex_charconst PARAMS ((const cpp_token *));
static void update_header_times PARAMS ((const char *)); static void update_header_times PARAMS ((const char *));
static int dump_one_header PARAMS ((splay_tree_node, void *)); static int dump_one_header PARAMS ((splay_tree_node, void *));
static void cb_ident PARAMS ((cpp_reader *, const cpp_string *)); static void cb_ident PARAMS ((cpp_reader *, unsigned int,
const cpp_string *));
static void cb_file_change PARAMS ((cpp_reader *, const cpp_file_change *)); static void cb_file_change PARAMS ((cpp_reader *, const cpp_file_change *));
static void cb_def_pragma PARAMS ((cpp_reader *)); static void cb_def_pragma PARAMS ((cpp_reader *, unsigned int));
static void cb_define PARAMS ((cpp_reader *, cpp_hashnode *)); static void cb_define PARAMS ((cpp_reader *, unsigned int,
static void cb_undef PARAMS ((cpp_reader *, cpp_hashnode *)); cpp_hashnode *));
static void cb_undef PARAMS ((cpp_reader *, unsigned int,
cpp_hashnode *));
const char * const char *
init_c_lex (filename) init_c_lex (filename)
...@@ -222,8 +225,9 @@ dump_time_statistics () ...@@ -222,8 +225,9 @@ dump_time_statistics ()
No need to deal with linemarkers under normal conditions. */ No need to deal with linemarkers under normal conditions. */
static void static void
cb_ident (pfile, str) cb_ident (pfile, line, str)
cpp_reader *pfile ATTRIBUTE_UNUSED; cpp_reader *pfile ATTRIBUTE_UNUSED;
unsigned int line ATTRIBUTE_UNUSED;
const cpp_string *str ATTRIBUTE_UNUSED; const cpp_string *str ATTRIBUTE_UNUSED;
{ {
#ifdef ASM_OUTPUT_IDENT #ifdef ASM_OUTPUT_IDENT
...@@ -306,8 +310,9 @@ cb_file_change (pfile, fc) ...@@ -306,8 +310,9 @@ cb_file_change (pfile, fc)
} }
static void static void
cb_def_pragma (pfile) cb_def_pragma (pfile, line)
cpp_reader *pfile; cpp_reader *pfile;
unsigned int line ATTRIBUTE_UNUSED;
{ {
/* Issue a warning message if we have been asked to do so. Ignore /* Issue a warning message if we have been asked to do so. Ignore
unknown pragmas in system headers unless an explicit unknown pragmas in system headers unless an explicit
...@@ -333,8 +338,9 @@ cb_def_pragma (pfile) ...@@ -333,8 +338,9 @@ cb_def_pragma (pfile)
/* #define callback for DWARF and DWARF2 debug info. */ /* #define callback for DWARF and DWARF2 debug info. */
static void static void
cb_define (pfile, node) cb_define (pfile, line, node)
cpp_reader *pfile; cpp_reader *pfile;
unsigned int line ATTRIBUTE_UNUSED;
cpp_hashnode *node; cpp_hashnode *node;
{ {
(*debug_hooks->define) (cpp_get_line (pfile)->line, (*debug_hooks->define) (cpp_get_line (pfile)->line,
...@@ -343,8 +349,9 @@ cb_define (pfile, node) ...@@ -343,8 +349,9 @@ cb_define (pfile, node)
/* #undef callback for DWARF and DWARF2 debug info. */ /* #undef callback for DWARF and DWARF2 debug info. */
static void static void
cb_undef (pfile, node) cb_undef (pfile, line, node)
cpp_reader *pfile; cpp_reader *pfile;
unsigned int line ATTRIBUTE_UNUSED;
cpp_hashnode *node; cpp_hashnode *node;
{ {
(*debug_hooks->undef) (cpp_get_line (pfile)->line, (*debug_hooks->undef) (cpp_get_line (pfile)->line,
......
...@@ -261,6 +261,7 @@ struct cpp_reader ...@@ -261,6 +261,7 @@ struct cpp_reader
/* The position of the last lexed token and last lexed directive. */ /* The position of the last lexed token and last lexed directive. */
cpp_lexer_pos lexer_pos; cpp_lexer_pos lexer_pos;
cpp_lexer_pos directive_pos; cpp_lexer_pos directive_pos;
unsigned int directive_line;
/* Memory pools. */ /* Memory pools. */
cpp_pool ident_pool; /* For all identifiers, and permanent cpp_pool ident_pool; /* For all identifiers, and permanent
......
...@@ -225,6 +225,7 @@ start_directive (pfile) ...@@ -225,6 +225,7 @@ start_directive (pfile)
/* Some handlers need the position of the # for diagnostics. */ /* Some handlers need the position of the # for diagnostics. */
pfile->directive_pos = pfile->lexer_pos; pfile->directive_pos = pfile->lexer_pos;
pfile->directive_line = pfile->line;
/* Don't save directive tokens for external clients. */ /* Don't save directive tokens for external clients. */
pfile->la_saved = pfile->la_write; pfile->la_saved = pfile->la_write;
...@@ -476,7 +477,7 @@ do_define (pfile) ...@@ -476,7 +477,7 @@ do_define (pfile)
{ {
if (_cpp_create_definition (pfile, node)) if (_cpp_create_definition (pfile, node))
if (pfile->cb.define) if (pfile->cb.define)
(*pfile->cb.define) (pfile, node); (*pfile->cb.define) (pfile, pfile->directive_line, node);
} }
} }
...@@ -492,7 +493,7 @@ do_undef (pfile) ...@@ -492,7 +493,7 @@ do_undef (pfile)
if (node && node->type == NT_MACRO) if (node && node->type == NT_MACRO)
{ {
if (pfile->cb.undef) if (pfile->cb.undef)
(*pfile->cb.undef) (pfile, node); (*pfile->cb.undef) (pfile, pfile->directive_line, node);
if (node->flags & NODE_WARN) if (node->flags & NODE_WARN)
cpp_warning (pfile, "undefining \"%s\"", NODE_NAME (node)); cpp_warning (pfile, "undefining \"%s\"", NODE_NAME (node));
...@@ -625,7 +626,8 @@ do_include_common (pfile, type) ...@@ -625,7 +626,8 @@ do_include_common (pfile, type)
/* Get out of macro context, if we are. */ /* Get out of macro context, if we are. */
end_directive (pfile, 1); end_directive (pfile, 1);
if (pfile->cb.include) if (pfile->cb.include)
(*pfile->cb.include) (pfile, pfile->directive->name, &header); (*pfile->cb.include) (pfile, pfile->directive_line,
pfile->directive->name, &header);
_cpp_execute_include (pfile, &header, type); _cpp_execute_include (pfile, &header, type);
} }
...@@ -888,7 +890,7 @@ do_ident (pfile) ...@@ -888,7 +890,7 @@ do_ident (pfile)
if (str.type != CPP_STRING) if (str.type != CPP_STRING)
cpp_error (pfile, "invalid #ident"); cpp_error (pfile, "invalid #ident");
else if (pfile->cb.ident) else if (pfile->cb.ident)
(*pfile->cb.ident) (pfile, &str.val.str); (*pfile->cb.ident) (pfile, pfile->directive_line, &str.val.str);
check_eol (pfile); check_eol (pfile);
} }
...@@ -1042,7 +1044,7 @@ do_pragma (pfile) ...@@ -1042,7 +1044,7 @@ do_pragma (pfile)
if (handler) if (handler)
(*handler) (pfile); (*handler) (pfile);
else if (pfile->cb.def_pragma) else if (pfile->cb.def_pragma)
(*pfile->cb.def_pragma) (pfile); (*pfile->cb.def_pragma) (pfile, pfile->directive_line);
} }
static void static void
......
...@@ -401,12 +401,12 @@ struct cpp_file_change ...@@ -401,12 +401,12 @@ struct cpp_file_change
struct cpp_callbacks struct cpp_callbacks
{ {
void (*file_change) PARAMS ((cpp_reader *, const cpp_file_change *)); void (*file_change) PARAMS ((cpp_reader *, const cpp_file_change *));
void (*include) PARAMS ((cpp_reader *, const unsigned char *, void (*include) PARAMS ((cpp_reader *, unsigned int,
const cpp_token *)); const unsigned char *, const cpp_token *));
void (*define) PARAMS ((cpp_reader *, cpp_hashnode *)); void (*define) PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
void (*undef) PARAMS ((cpp_reader *, cpp_hashnode *)); void (*undef) PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
void (*ident) PARAMS ((cpp_reader *, const cpp_string *)); void (*ident) PARAMS ((cpp_reader *, unsigned int, const cpp_string *));
void (*def_pragma) PARAMS ((cpp_reader *)); void (*def_pragma) PARAMS ((cpp_reader *, unsigned int));
}; };
#define CPP_FATAL_LIMIT 1000 #define CPP_FATAL_LIMIT 1000
......
...@@ -54,13 +54,14 @@ static void maybe_print_line PARAMS ((unsigned int)); ...@@ -54,13 +54,14 @@ static void maybe_print_line PARAMS ((unsigned int));
/* Callback routines for the parser. Most of these are active only /* Callback routines for the parser. Most of these are active only
in specific modes. */ in specific modes. */
static void cb_define PARAMS ((cpp_reader *, cpp_hashnode *)); static void cb_define PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
static void cb_undef PARAMS ((cpp_reader *, cpp_hashnode *)); static void cb_undef PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
static void cb_include PARAMS ((cpp_reader *, const unsigned char *, static void cb_include PARAMS ((cpp_reader *, unsigned int,
const cpp_token *)); const unsigned char *, const cpp_token *));
static void cb_ident PARAMS ((cpp_reader *, const cpp_string *)); static void cb_ident PARAMS ((cpp_reader *, unsigned int,
const cpp_string *));
static void cb_file_change PARAMS ((cpp_reader *, const cpp_file_change *)); static void cb_file_change PARAMS ((cpp_reader *, const cpp_file_change *));
static void cb_def_pragma PARAMS ((cpp_reader *)); static void cb_def_pragma PARAMS ((cpp_reader *, unsigned int));
const char *progname; /* Needs to be global. */ const char *progname; /* Needs to be global. */
static cpp_reader *pfile; /* An opaque handle. */ static cpp_reader *pfile; /* An opaque handle. */
...@@ -345,8 +346,9 @@ print_line (special_flags) ...@@ -345,8 +346,9 @@ print_line (special_flags)
/* Callbacks. */ /* Callbacks. */
static void static void
cb_ident (pfile, str) cb_ident (pfile, line, str)
cpp_reader *pfile ATTRIBUTE_UNUSED; cpp_reader *pfile ATTRIBUTE_UNUSED;
unsigned int line ATTRIBUTE_UNUSED;
const cpp_string * str; const cpp_string * str;
{ {
maybe_print_line (cpp_get_line (pfile)->output_line); maybe_print_line (cpp_get_line (pfile)->output_line);
...@@ -355,8 +357,9 @@ cb_ident (pfile, str) ...@@ -355,8 +357,9 @@ cb_ident (pfile, str)
} }
static void static void
cb_define (pfile, node) cb_define (pfile, line, node)
cpp_reader *pfile; cpp_reader *pfile;
unsigned int line ATTRIBUTE_UNUSED;
cpp_hashnode *node; cpp_hashnode *node;
{ {
maybe_print_line (cpp_get_line (pfile)->output_line); maybe_print_line (cpp_get_line (pfile)->output_line);
...@@ -373,8 +376,9 @@ cb_define (pfile, node) ...@@ -373,8 +376,9 @@ cb_define (pfile, node)
} }
static void static void
cb_undef (pfile, node) cb_undef (pfile, line, node)
cpp_reader *pfile; cpp_reader *pfile;
unsigned int line ATTRIBUTE_UNUSED;
cpp_hashnode *node; cpp_hashnode *node;
{ {
maybe_print_line (cpp_get_line (pfile)->output_line); maybe_print_line (cpp_get_line (pfile)->output_line);
...@@ -383,8 +387,9 @@ cb_undef (pfile, node) ...@@ -383,8 +387,9 @@ cb_undef (pfile, node)
} }
static void static void
cb_include (pfile, dir, header) cb_include (pfile, line, dir, header)
cpp_reader *pfile ATTRIBUTE_UNUSED; cpp_reader *pfile ATTRIBUTE_UNUSED;
unsigned int line ATTRIBUTE_UNUSED;
const unsigned char *dir; const unsigned char *dir;
const cpp_token *header; const cpp_token *header;
{ {
...@@ -429,8 +434,9 @@ cb_file_change (pfile, fc) ...@@ -429,8 +434,9 @@ cb_file_change (pfile, fc)
/* Copy a #pragma directive to the preprocessed output. LINE is the /* Copy a #pragma directive to the preprocessed output. LINE is the
line of the current source file, not the logical line. */ line of the current source file, not the logical line. */
static void static void
cb_def_pragma (pfile) cb_def_pragma (pfile, line)
cpp_reader *pfile; cpp_reader *pfile;
unsigned int line ATTRIBUTE_UNUSED;
{ {
maybe_print_line (cpp_get_line (pfile)->output_line); maybe_print_line (cpp_get_line (pfile)->output_line);
fputs ("#pragma ", print.outf); fputs ("#pragma ", print.outf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment