diff options
author | Neil Booth <neil@gcc.gnu.org> | 2001-08-11 07:33:39 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2001-08-11 07:33:39 +0000 |
commit | 47d89cf3e65223298aef15f371a4e59511e0ad31 (patch) | |
tree | c6597f82b6f803c65532fe99e5912e516912053f /gcc/cpplib.c | |
parent | 16568b922ec8cd76f86cfe0a492c298c7c4f6d67 (diff) | |
download | gcc-47d89cf3e65223298aef15f371a4e59511e0ad31.zip gcc-47d89cf3e65223298aef15f371a4e59511e0ad31.tar.gz gcc-47d89cf3e65223298aef15f371a4e59511e0ad31.tar.bz2 |
c-lex.c (map): Make const.
* c-lex.c (map): Make const.
(cb_file_change): Update for callback passing a line map.
Don't assume we have a previous map. Remove sanity check
about popping too many files.
* cpperror.c (print_location): Make map const.
* cppfiles.c (stack_include_file): Update; line maps now hold sysp.
(cpp_make_system_header): Similarly.
(search_from): Similarly.
(_cpp_execute_include): Don't remember where we came from.
* cpphash.h (struct cpp_buffer): Remove return_to_line, sysp.
(struct cpp_reader): Make map const.
(CPP_IN_SYSTEM_HEADER, _cpp_do_file_change): Update.
* cpplib.c (do_line): Update; line maps now hold sysp.
(cpp_push_buffer): Similarly.
(_cpp_do_file_change): Similarly; callback with map instead.
(cpp_get_line_maps): Constify return value.
(_cpp_pop_buffer): Update.
* cpplib.h (struct cpp_file_change): Remove.
(struct cpp_callbacks): Update.
(cpp_get_line_maps): Constify return value.
* cppmacro.c (_cpp_create_definition): Update.
* cppmain.c (struct printer): Constify map.
(maybe_print_line): Similarly.
(print_line): Similarly. Deduce flags 1 and 2 here.
(cb_file_change): Update.
* line-map.c (free_line_maps): Warn regardless.
(add_line_map): Return pointer to const. When passed NULL to_file
with LC_LEAVE, use the obvious values for the return point so the
caller doesn't have to figure them out.
(lookup_line): Return pointer to const.
(print_containing_files): Take pointer to const.
* line-map.h (struct line_map): New members reason, sysp.
(add_line_map): Return pointer to const.
(lookup_line): Similarly.
(print_containing_files): Take pointer to const.
From-SVN: r44789
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 4710beb..9404a00 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -713,7 +713,7 @@ do_line (pfile) cpp_buffer *buffer = pfile->buffer; enum lc_reason reason = LC_RENAME; unsigned long new_lineno; - unsigned int cap; + unsigned int cap, sysp = pfile->map->sysp; cpp_token token; /* C99 raised the minimum limit on #line numbers. */ @@ -741,9 +741,10 @@ do_line (pfile) /* Only accept flags for the # 55 form. */ if (pfile->state.line_extension) { - int flag = 0, sysp = 0; + int flag; - flag = read_flag (pfile, flag); + sysp = 0; + flag = read_flag (pfile, 0); if (flag == 1) { reason = LC_ENTER; @@ -763,7 +764,6 @@ do_line (pfile) if (flag == 4) sysp = 2; } - buffer->sysp = sysp; } check_eol (pfile); } @@ -775,34 +775,27 @@ do_line (pfile) } end_directive (pfile, 1); - _cpp_do_file_change (pfile, reason, new_lineno); + _cpp_do_file_change (pfile, reason, (const char *) buffer->nominal_fname, + new_lineno, sysp); } /* Arrange the file_change callback. pfile->line has changed to - FILE_LINE of the current buffer, for reason REASON. */ + FILE_LINE of TO_FILE, for reason REASON. SYSP is 1 for a system + header, 2 for a sytem header that needs to be extern "C" protected, + and zero otherwise. */ void -_cpp_do_file_change (pfile, reason, file_line) +_cpp_do_file_change (pfile, reason, to_file, file_line, sysp) cpp_reader *pfile; enum lc_reason reason; + const char *to_file; unsigned int file_line; + unsigned int sysp; { - cpp_buffer *buffer = pfile->buffer; - - pfile->map = add_line_map (&pfile->line_maps, reason, - pfile->line, buffer->nominal_fname, file_line); + pfile->map = add_line_map (&pfile->line_maps, reason, sysp, + pfile->line, to_file, file_line); if (pfile->cb.file_change) - { - cpp_file_change fc; - - fc.map = pfile->map; - fc.line = pfile->line; - fc.reason = reason; - fc.sysp = buffer->sysp; - fc.externc = CPP_OPTION (pfile, cplusplus) && buffer->sysp == 2; - - (*pfile->cb.file_change) (pfile, &fc); - } + (*pfile->cb.file_change) (pfile, pfile->map); } /* @@ -908,7 +901,8 @@ cpp_register_pragma (pfile, space, name, handler) } found: - new = xnew (struct pragma_entry); + new = (struct pragma_entry *) + _cpp_pool_alloc (&pfile->macro_pool, sizeof (struct pragma_entry)); new->name = name; new->len = strlen (name); new->isnspace = 0; @@ -936,7 +930,8 @@ cpp_register_pragma_space (pfile, space) p = p->next; } - new = xnew (struct pragma_entry); + new = (struct pragma_entry *) + _cpp_pool_alloc (&pfile->macro_pool, sizeof (struct pragma_entry)); new->name = space; new->len = len; new->isnspace = 1; @@ -1722,7 +1717,7 @@ cpp_get_callbacks (pfile) } /* The line map set. */ -struct line_maps * +const struct line_maps * cpp_get_line_maps (pfile) cpp_reader *pfile; { @@ -1764,7 +1759,6 @@ cpp_push_buffer (pfile, buffer, len, type, filename, return_at_eof) new->line_base = new->buf = new->cur = buffer; new->rlimit = buffer + len; - new->sysp = 0; /* No read ahead or extra char initially. */ new->read_ahead = EOF; @@ -1813,7 +1807,7 @@ _cpp_pop_buffer (pfile) { /* Callbacks are not generated for popping the main file. */ if (buffer->prev) - _cpp_do_file_change (pfile, LC_LEAVE, buffer->prev->return_to_line); + _cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0); _cpp_pop_file_buffer (pfile, buffer); } |