diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-17 22:23:49 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-17 22:23:49 +0000 |
commit | 5a9f87bb4f047042c9b67dc3d22c275b4c41c24d (patch) | |
tree | 1119c95193138295f135f3d1be8fd1f94c827ca3 /gcc | |
parent | d408664a548e346c6323cae2a41dd1156f8d9c33 (diff) | |
download | gcc-5a9f87bb4f047042c9b67dc3d22c275b4c41c24d.tar.gz |
* cpperror.c (print_location): Don't take a file name; use the
line map instead.
(_cpp_begin_message): Similarly.
(cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning,
cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line): Update.
(cpp_pedwarn_with_file_and_line): Remove.
* cppfiles.c (stack_include_file): Update; set filename to stdin
here when appropriate.
* cpphash.h (struct cpp_buffer): Remove nominal_fname.
(_cpp_begin_message): Don't take a file name.
* cppinit.c: Add comment.
* cpplex.c: Fix end-of-directive indicator.
* cpplib.c: Don't include intl.h.
(run_directive, do_diagnostic): Update.
(do_line): Update to not use nominal_fname.
(cpp_push_buffer): Don't take a filename.
* cpplib.h (struct ht): Remove.
(cpp_push_buffer): Don't take a filename.
(cpp_pedwarn_with_file_and_line): Remove.
* cppmacro.c (struct cpp_macro): Remove file.
(builtin_macro): Update.
(_cpp_create_definition): Update.
* cppmain.c: Correct comment.
* fix-header.c (read_scan_file): Update.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44986 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 27 | ||||
-rw-r--r-- | gcc/cpperror.c | 107 | ||||
-rw-r--r-- | gcc/cppfiles.c | 8 | ||||
-rw-r--r-- | gcc/cpphash.h | 5 | ||||
-rw-r--r-- | gcc/cppinit.c | 5 | ||||
-rw-r--r-- | gcc/cpplex.c | 2 | ||||
-rw-r--r-- | gcc/cpplib.c | 40 | ||||
-rw-r--r-- | gcc/cpplib.h | 6 | ||||
-rw-r--r-- | gcc/cppmacro.c | 14 | ||||
-rw-r--r-- | gcc/cppmain.c | 3 | ||||
-rw-r--r-- | gcc/fix-header.c | 2 |
11 files changed, 85 insertions, 134 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 29ca30140e9..4272041fdd1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,30 @@ +2001-08-17 Neil Booth <neil@daikokuya.demon.co.uk> + + * cpperror.c (print_location): Don't take a file name; use the + line map instead. + (_cpp_begin_message): Similarly. + (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, + cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line): Update. + (cpp_pedwarn_with_file_and_line): Remove. + * cppfiles.c (stack_include_file): Update; set filename to stdin + here when appropriate. + * cpphash.h (struct cpp_buffer): Remove nominal_fname. + (_cpp_begin_message): Don't take a file name. + * cppinit.c: Add comment. + * cpplex.c: Fix end-of-directive indicator. + * cpplib.c: Don't include intl.h. + (run_directive, do_diagnostic): Update. + (do_line): Update to not use nominal_fname. + (cpp_push_buffer): Don't take a filename. + * cpplib.h (struct ht): Remove. + (cpp_push_buffer): Don't take a filename. + (cpp_pedwarn_with_file_and_line): Remove. + * cppmacro.c (struct cpp_macro): Remove file. + (builtin_macro): Update. + (_cpp_create_definition): Update. + * cppmain.c: Correct comment. + * fix-header.c (read_scan_file): Update. + 2001-08-17 Kazu Hirata <kazu@hxi.com> * sbitmap.c: Fix comment formatting. diff --git a/gcc/cpperror.c b/gcc/cpperror.c index 73cb418b473..84d1c837e23 100644 --- a/gcc/cpperror.c +++ b/gcc/cpperror.c @@ -30,7 +30,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "intl.h" static void print_location PARAMS ((cpp_reader *, - const char *, const cpp_lexer_pos *)); /* Don't remove the blank before do, as otherwise the exgettext @@ -39,9 +38,8 @@ static void print_location PARAMS ((cpp_reader *, do { vfprintf (stderr, _(msgid), ap); putc ('\n', stderr); } while (0) static void -print_location (pfile, filename, pos) +print_location (pfile, pos) cpp_reader *pfile; - const char *filename; const cpp_lexer_pos *pos; { cpp_buffer *buffer = pfile->buffer; @@ -50,47 +48,28 @@ print_location (pfile, filename, pos) fprintf (stderr, "%s: ", progname); else { - unsigned int line, col = 0; - enum cpp_buffer_type type = buffer->type; - - /* For _Pragma buffers, we want to print the location as - "foo.c:5:8: _Pragma:", where foo.c is the containing buffer. - For diagnostics relating to command line options, we want to - print "<command line>:" with no line number. */ - if (type == BUF_CL_OPTION || type == BUF_BUILTIN) - line = 0; - else - { - const struct line_map *map; - - if (type == BUF_PRAGMA) - buffer = buffer->prev; - - if (pos == 0) - pos = cpp_get_line (pfile); - map = lookup_line (&pfile->line_maps, pos->line); - line = SOURCE_LINE (map, pos->line); - if (filename == 0) - filename = map->to_file; + unsigned int line, col; + const struct line_map *map; - col = pos->col; - if (col == 0) - col = 1; + if (pos == 0) + pos = cpp_get_line (pfile); + map = lookup_line (&pfile->line_maps, pos->line); - print_containing_files (&pfile->line_maps, map); - } + print_containing_files (&pfile->line_maps, map); - if (filename == 0) - filename = buffer->nominal_fname; + line = SOURCE_LINE (map, pos->line); + col = pos->col; + if (col == 0) + col = 1; if (line == 0) - fprintf (stderr, "%s:", filename); + fprintf (stderr, "%s:", map->to_file); else if (CPP_OPTION (pfile, show_column) == 0) - fprintf (stderr, "%s:%u:", filename, line); + fprintf (stderr, "%s:%u:", map->to_file, line); else - fprintf (stderr, "%s:%u:%u:", filename, line, col); + fprintf (stderr, "%s:%u:%u:", map->to_file, line, col); - if (type == BUF_PRAGMA) + if (buffer->type == BUF_PRAGMA) fprintf (stderr, "_Pragma:"); fputc (' ', stderr); } @@ -101,10 +80,9 @@ print_location (pfile, filename, pos) If it returns 0, this error has been suppressed. */ int -_cpp_begin_message (pfile, code, file, pos) +_cpp_begin_message (pfile, code, pos) cpp_reader *pfile; enum error_type code; - const char *file; const cpp_lexer_pos *pos; { int is_warning = 0; @@ -149,7 +127,7 @@ _cpp_begin_message (pfile, code, file, pos) break; } - print_location (pfile, file, pos); + print_location (pfile, pos); if (is_warning) fputs (_("warning: "), stderr); @@ -177,7 +155,7 @@ cpp_ice VPARAMS ((cpp_reader *pfile, const char *msgid, ...)) msgid = va_arg (ap, const char *); #endif - if (_cpp_begin_message (pfile, ICE, NULL, 0)) + if (_cpp_begin_message (pfile, ICE, 0)) v_message (msgid, ap); va_end(ap); } @@ -204,7 +182,7 @@ cpp_fatal VPARAMS ((cpp_reader *pfile, const char *msgid, ...)) msgid = va_arg (ap, const char *); #endif - if (_cpp_begin_message (pfile, FATAL, NULL, 0)) + if (_cpp_begin_message (pfile, FATAL, 0)) v_message (msgid, ap); va_end(ap); } @@ -225,7 +203,7 @@ cpp_error VPARAMS ((cpp_reader * pfile, const char *msgid, ...)) msgid = va_arg (ap, const char *); #endif - if (_cpp_begin_message (pfile, ERROR, NULL, 0)) + if (_cpp_begin_message (pfile, ERROR, 0)) v_message (msgid, ap); va_end(ap); } @@ -254,7 +232,7 @@ cpp_error_with_line VPARAMS ((cpp_reader *pfile, int line, int column, pos.line = line; pos.col = column; - if (_cpp_begin_message (pfile, ERROR, NULL, &pos)) + if (_cpp_begin_message (pfile, ERROR, &pos)) v_message (msgid, ap); va_end(ap); } @@ -284,7 +262,7 @@ cpp_warning VPARAMS ((cpp_reader * pfile, const char *msgid, ...)) msgid = va_arg (ap, const char *); #endif - if (_cpp_begin_message (pfile, WARNING, NULL, 0)) + if (_cpp_begin_message (pfile, WARNING, 0)) v_message (msgid, ap); va_end(ap); } @@ -313,7 +291,7 @@ cpp_warning_with_line VPARAMS ((cpp_reader * pfile, int line, int column, pos.line = line; pos.col = column; - if (_cpp_begin_message (pfile, WARNING, NULL, &pos)) + if (_cpp_begin_message (pfile, WARNING, &pos)) v_message (msgid, ap); va_end(ap); } @@ -334,7 +312,7 @@ cpp_pedwarn VPARAMS ((cpp_reader * pfile, const char *msgid, ...)) msgid = va_arg (ap, const char *); #endif - if (_cpp_begin_message (pfile, PEDWARN, NULL, 0)) + if (_cpp_begin_message (pfile, PEDWARN, 0)) v_message (msgid, ap); va_end(ap); } @@ -363,42 +341,7 @@ cpp_pedwarn_with_line VPARAMS ((cpp_reader * pfile, int line, int column, pos.line = line; pos.col = column; - if (_cpp_begin_message (pfile, PEDWARN, NULL, &pos)) - v_message (msgid, ap); - va_end(ap); -} - -/* Report a warning (or an error if pedantic_errors) - giving specified file name and line number, not current. */ - -void -cpp_pedwarn_with_file_and_line VPARAMS ((cpp_reader *pfile, - const char *file, int line, int col, - const char *msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - cpp_reader *pfile; - const char *file; - int line; - int col; - const char *msgid; -#endif - va_list ap; - cpp_lexer_pos pos; - - VA_START (ap, msgid); - -#ifndef ANSI_PROTOTYPES - pfile = va_arg (ap, cpp_reader *); - file = va_arg (ap, const char *); - line = va_arg (ap, int); - col = va_arg (ap, int); - msgid = va_arg (ap, const char *); -#endif - - pos.line = line; - pos.col = col; - if (_cpp_begin_message (pfile, PEDWARN, file, &pos)) + if (_cpp_begin_message (pfile, PEDWARN, &pos)) v_message (msgid, ap); va_end(ap); } diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 657130400f1..237e84f024a 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -287,6 +287,7 @@ stack_include_file (pfile, inc) size_t len = 0; cpp_buffer *fp; int sysp, deps_sysp; + const char *filename; /* We'll try removing deps_sysp after the release of 3.0. */ deps_sysp = pfile->system_include_depth != 0; @@ -326,7 +327,7 @@ stack_include_file (pfile, inc) } /* Push a buffer. */ - fp = cpp_push_buffer (pfile, inc->buffer, len, BUF_FILE, inc->name, 0); + fp = cpp_push_buffer (pfile, inc->buffer, len, BUF_FILE, 0); fp->inc = inc; fp->inc->refcnt++; @@ -336,7 +337,10 @@ stack_include_file (pfile, inc) pfile->include_depth++; /* Generate the call back. */ - _cpp_do_file_change (pfile, LC_ENTER, fp->nominal_fname, 1, sysp); + filename = inc->name; + if (*filename == '\0') + filename = _("<stdin>"); + _cpp_do_file_change (pfile, LC_ENTER, filename, 1, sysp); } /* Read the file referenced by INC into the file cache. diff --git a/gcc/cpphash.h b/gcc/cpphash.h index 27e221c6b58..0a24f4d6c5c 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -176,9 +176,6 @@ struct cpp_buffer const unsigned char *buf; /* entire buffer */ - /* Filename specified with #line command. */ - const char *nominal_fname; - /* Pointer into the include table. Used for include_next and to record control macros. */ struct include_file *inc; @@ -375,7 +372,7 @@ extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1]; /* In cpperror.c */ enum error_type { WARNING = 0, WARNING_SYSHDR, PEDWARN, ERROR, FATAL, ICE }; extern int _cpp_begin_message PARAMS ((cpp_reader *, enum error_type, - const char *, const cpp_lexer_pos *)); + const cpp_lexer_pos *)); /* In cppmacro.c */ extern void _cpp_free_definition PARAMS ((cpp_hashnode *)); diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 63bcfdd3735..4a78a938987 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -861,7 +861,7 @@ init_standard_includes (pfile) || (CPP_OPTION (pfile, cplusplus) && !CPP_OPTION (pfile, no_standard_cplusplus_includes))) { - char *str = xstrdup (update_path (p->fname, p->component)); + char *str = update_path (p->fname, p->component); append_include_chain (pfile, str, SYSTEM, p->cxx_aware); } } @@ -939,6 +939,9 @@ cpp_start_read (pfile, fname) if (!_cpp_read_file (pfile, fname)) return 0; + /* FIXME: we want to set up linemaps with _("<builtin>") and + _("<command line>") somewhere round here. Harder than it looks. */ + /* If already preprocessed, don't install __LINE__, etc., and ignore command line definitions and assertions. Handle -U's, -D's and -A's in the order they were seen. */ diff --git a/gcc/cpplex.c b/gcc/cpplex.c index 9446aae592e..e1657a783ce 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -894,7 +894,7 @@ _cpp_lex_token (pfile, result) in-progress directives and arguments have been taken care of. Decrement the line to terminate an in-progress directive. */ if (pfile->state.in_directive) - pfile->line--; + pfile->lexer_pos.output_line = pfile->line--; else if (! pfile->state.parsing_args) { /* Non-empty files should end in a newline. Don't warn for diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 9404a00ea8e..eab9f31c3d6 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -24,7 +24,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "cpplib.h" #include "cpphash.h" -#include "intl.h" #include "obstack.h" /* Chained list of answers to an assertion. */ @@ -403,7 +402,7 @@ run_directive (pfile, dir_no, type, buf, count) { cpp_buffer *buffer; - buffer = cpp_push_buffer (pfile, (const U_CHAR *) buf, count, type, 0, 1); + buffer = cpp_push_buffer (pfile, (const U_CHAR *) buf, count, type, 1); start_directive (pfile); pfile->state.prevent_expansion++; pfile->directive = &dtable[dir_no]; @@ -710,11 +709,11 @@ static void do_line (pfile) cpp_reader *pfile; { - cpp_buffer *buffer = pfile->buffer; - enum lc_reason reason = LC_RENAME; - unsigned long new_lineno; - unsigned int cap, sysp = pfile->map->sysp; cpp_token token; + const char *new_file = pfile->map->to_file; + unsigned long new_lineno; + unsigned int cap, new_sysp = pfile->map->sysp; + enum lc_reason reason = LC_RENAME; /* C99 raised the minimum limit on #line numbers. */ cap = CPP_OPTION (pfile, c99) ? 2147483647 : 32767; @@ -736,20 +735,20 @@ do_line (pfile) cpp_get_token (pfile, &token); if (token.type == CPP_STRING) { - buffer->nominal_fname = (const char *) token.val.str.text; + new_file = (const char *) token.val.str.text; /* Only accept flags for the # 55 form. */ if (pfile->state.line_extension) { int flag; - sysp = 0; + new_sysp = 0; flag = read_flag (pfile, 0); if (flag == 1) { reason = LC_ENTER; /* Fake an include for cpp_included (). */ - _cpp_fake_include (pfile, buffer->nominal_fname); + _cpp_fake_include (pfile, new_file); flag = read_flag (pfile, flag); } else if (flag == 2) @@ -759,10 +758,10 @@ do_line (pfile) } if (flag == 3) { - sysp = 1; + new_sysp = 1; flag = read_flag (pfile, flag); if (flag == 4) - sysp = 2; + new_sysp = 2; } } check_eol (pfile); @@ -775,8 +774,7 @@ do_line (pfile) } end_directive (pfile, 1); - _cpp_do_file_change (pfile, reason, (const char *) buffer->nominal_fname, - new_lineno, sysp); + _cpp_do_file_change (pfile, reason, new_file, new_lineno, new_sysp); } /* Arrange the file_change callback. pfile->line has changed to @@ -809,7 +807,7 @@ do_diagnostic (pfile, code, print_dir) enum error_type code; int print_dir; { - if (_cpp_begin_message (pfile, code, NULL, 0)) + if (_cpp_begin_message (pfile, code, 0)) { if (print_dir) fprintf (stderr, "#%s ", pfile->directive->name); @@ -1737,23 +1735,15 @@ cpp_set_callbacks (pfile, cb) doesn't fail. It does not generate a file change call back; that is the responsibility of the caller. */ cpp_buffer * -cpp_push_buffer (pfile, buffer, len, type, filename, return_at_eof) +cpp_push_buffer (pfile, buffer, len, type, return_at_eof) cpp_reader *pfile; const U_CHAR *buffer; size_t len; enum cpp_buffer_type type; - const char *filename; int return_at_eof; { cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer); - if (type == BUF_BUILTIN) - filename = _("<builtin>"); - else if (type == BUF_CL_OPTION) - filename = _("<command line>"); - else if (type == BUF_PRAGMA) - filename = "<_Pragma>"; - /* Clears, amongst other things, if_stack and mi_cmacro. */ memset (new, 0, sizeof (cpp_buffer)); @@ -1768,10 +1758,6 @@ cpp_push_buffer (pfile, buffer, len, type, filename, return_at_eof) options don't do trigraph and escaped newline processing. */ new->from_stage3 = type != BUF_FILE || CPP_OPTION (pfile, preprocessed); - if (*filename == '\0') - new->nominal_fname = _("<stdin>"); - else - new->nominal_fname = filename; new->type = type; new->prev = pfile->buffer; new->pfile = pfile; diff --git a/gcc/cpplib.h b/gcc/cpplib.h index acce60620fd..9fc058d50af 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -47,7 +47,6 @@ typedef struct cpp_callbacks cpp_callbacks; struct answer; struct file_name_map_list; -struct ht; /* The first two groups, apart from '=', can appear in preprocessor expressions. This allows a lookup table to be implemented in @@ -542,8 +541,7 @@ extern void cpp_unassert PARAMS ((cpp_reader *, const char *)); extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *, const unsigned char *, size_t, - enum cpp_buffer_type, - const char *, int)); + enum cpp_buffer_type, int)); extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int)); /* N.B. The error-message-printer prototypes have not been nicely @@ -570,8 +568,6 @@ extern void cpp_warning_with_line PARAMS ((cpp_reader *, int, int, const char *m ATTRIBUTE_PRINTF_4; extern void cpp_pedwarn_with_line PARAMS ((cpp_reader *, int, int, const char *msgid, ...)) ATTRIBUTE_PRINTF_4; -extern void cpp_pedwarn_with_file_and_line PARAMS ((cpp_reader *, const char *, int, int, const char *msgid, ...)) - ATTRIBUTE_PRINTF_5; extern void cpp_error_from_errno PARAMS ((cpp_reader *, const char *)); extern void cpp_notice_from_errno PARAMS ((cpp_reader *, const char *)); diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index 09cad20553c..bc12913d8a6 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -33,7 +33,6 @@ struct cpp_macro { cpp_hashnode **params; /* Parameters, if any. */ cpp_token *expansion; /* First token of replacement list. */ - const char *file; /* Defined in file name. */ unsigned int line; /* Starting line number. */ unsigned int count; /* Number of tokens in expansion. */ unsigned short paramc; /* Number of parameters. */ @@ -152,13 +151,13 @@ builtin_macro (pfile, token) case BT_BASE_FILE: { const char *name; - cpp_buffer *buffer = pfile->buffer; + const struct line_map *map = pfile->map; if (node->value.builtin == BT_BASE_FILE) - while (buffer->prev) - buffer = buffer->prev; + while (! MAIN_FILE_P (map)) + map = INCLUDED_FROM (&pfile->line_maps, map); - name = buffer->nominal_fname; + name = map->to_file; make_string_token (&pfile->ident_pool, token, (const unsigned char *) name, strlen (name)); } @@ -1372,7 +1371,6 @@ _cpp_create_definition (pfile, node) macro = (cpp_macro *) _cpp_pool_alloc (&pfile->macro_pool, sizeof (cpp_macro)); - macro->file = pfile->buffer->nominal_fname; macro->line = pfile->directive_pos.line; macro->params = 0; macro->paramc = 0; @@ -1476,9 +1474,7 @@ _cpp_create_definition (pfile, node) "\"%s\" redefined", NODE_NAME (node)); if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN)) - cpp_pedwarn_with_file_and_line (pfile, - node->value.macro->file, - node->value.macro->line, 1, + cpp_pedwarn_with_line (pfile, node->value.macro->line, 1, "this is the location of the previous definition"); } _cpp_free_definition (node); diff --git a/gcc/cppmain.c b/gcc/cppmain.c index 5cb0746bece..b1166155908 100644 --- a/gcc/cppmain.c +++ b/gcc/cppmain.c @@ -419,8 +419,7 @@ cb_file_change (pfile, map) print.map = map; } -/* Copy a #pragma directive to the preprocessed output. LINE is the - line of the current source file, not the logical line. */ +/* Copy a #pragma directive to the preprocessed output. */ static void cb_def_pragma (pfile, line) cpp_reader *pfile; diff --git a/gcc/fix-header.c b/gcc/fix-header.c index baaabf85feb..2d7f8d4e59e 100644 --- a/gcc/fix-header.c +++ b/gcc/fix-header.c @@ -658,7 +658,7 @@ read_scan_file (in_fname, argc, argv) /* Scan the macro expansion of "getchar();". */ cpp_push_buffer (scan_in, getchar_call, sizeof(getchar_call) - 1, - BUF_BUILTIN, in_fname, 1); + BUF_BUILTIN, 1); for (;;) { cpp_token t; |