From 29401c300b273963c88bb08bb6282acdf11e75c2 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Wed, 22 Aug 2001 20:37:20 +0000 Subject: [PATCH] cpperror.c (print_location): Don't show _Pragma. * cpperror.c (print_location): Don't show _Pragma. * cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing and file change callback generation here. (stack_include_file): Update use of cpp_push_buffer. * cpphash.h (_cpp_pop_file_buffer): Update prototype. (struct cpp_buffer): Remove type, pfile members. * cppinit.c (cpp_handle_option): Use free_chain. * cpplex.c (_cpp_lex_token): Don't do -include file pushing here. (skip_escaped_newlines, get_effective_char, lex_percent): Take a cpp_reader rather than a cpp_buffer. (skip_escaped_newlines, get_effective_char, skip_block_comment, skip_line_comment, parse_string, lex_percent, lex_dot, _cpp_lex_token): Update accordingly. * cpplib.c (_cpp_pop_buffer): Don't do file change callback generation here. (cpp_push_buffer): Update prototype. (run_directive): Update use of cpp_push_buffer. (_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef, handle_assertion): Update use of run_directive. * cpplib.h (enum cpp_buffer_type): Remove. (cpp_push_buffer): Update prototype. * fix-header.c (read_scan_file): Update. From-SVN: r45112 --- gcc/ChangeLog | 25 ++++++++++++ gcc/cpperror.c | 2 - gcc/cppfiles.c | 24 ++++++++---- gcc/cpphash.h | 13 +++--- gcc/cppinit.c | 10 +---- gcc/cpplex.c | 100 +++++++++++++++++++++++------------------------ gcc/cpplib.c | 53 +++++++++---------------- gcc/cpplib.h | 6 +-- gcc/fix-header.c | 2 +- 9 files changed, 118 insertions(+), 117 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dde3c42aeaa..ffc804daacd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,28 @@ +2001-08-22 Neil Booth + + * cpperror.c (print_location): Don't show _Pragma. + * cppfiles.c (_cpp_pop_file_buffer): Handle -include file pushing + and file change callback generation here. + (stack_include_file): Update use of cpp_push_buffer. + * cpphash.h (_cpp_pop_file_buffer): Update prototype. + (struct cpp_buffer): Remove type, pfile members. + * cppinit.c (cpp_handle_option): Use free_chain. + * cpplex.c (_cpp_lex_token): Don't do -include file pushing here. + (skip_escaped_newlines, get_effective_char, lex_percent): Take + a cpp_reader rather than a cpp_buffer. + (skip_escaped_newlines, get_effective_char, skip_block_comment, + skip_line_comment, parse_string, lex_percent, lex_dot, + _cpp_lex_token): Update accordingly. + * cpplib.c (_cpp_pop_buffer): Don't do file change callback + generation here. + (cpp_push_buffer): Update prototype. + (run_directive): Update use of cpp_push_buffer. + (_cpp_do__Pragma, cpp_define, cpp_define_builtin, cpp_undef, + handle_assertion): Update use of run_directive. + * cpplib.h (enum cpp_buffer_type): Remove. + (cpp_push_buffer): Update prototype. + * fix-header.c (read_scan_file): Update. + 2001-08-22 Matt Kraai * gcc.c (struct prefix_list): Change prefix to const char *. diff --git a/gcc/cpperror.c b/gcc/cpperror.c index 6b137abcd75..3dbf534affd 100644 --- a/gcc/cpperror.c +++ b/gcc/cpperror.c @@ -69,8 +69,6 @@ print_location (pfile, pos) else fprintf (stderr, "%s:%u:%u:", map->to_file, line, col); - if (buffer->type == BUF_PRAGMA) - fprintf (stderr, "_Pragma:"); fputc (' ', stderr); } } diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index c8b28f94744..5b8f9076b39 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -317,7 +317,8 @@ stack_include_file (pfile, inc) inc->include_count++; /* Push a buffer. */ - fp = cpp_push_buffer (pfile, inc->buffer, inc->st.st_size, BUF_FILE, 0); + fp = cpp_push_buffer (pfile, inc->buffer, inc->st.st_size, + /* from_stage3 */ CPP_OPTION (pfile, preprocessed), 0); fp->inc = inc; fp->inc->refcnt++; @@ -720,14 +721,12 @@ _cpp_read_file (pfile, fname) } /* Do appropriate cleanup when a file buffer is popped off the input - stack. */ + stack. Push the next -include file, if any remain. */ void -_cpp_pop_file_buffer (pfile, buf) +_cpp_pop_file_buffer (pfile, inc) cpp_reader *pfile; - cpp_buffer *buf; + struct include_file *inc; { - struct include_file *inc = buf->inc; - /* Record the inclusion-preventing macro, which could be NULL meaning no controlling macro. */ if (pfile->mi_valid && inc->cmacro == NULL) @@ -739,6 +738,16 @@ _cpp_pop_file_buffer (pfile, buf) inc->refcnt--; if (inc->refcnt == 0 && DO_NOT_REREAD (inc)) purge_cache (inc); + + /* Don't generate a callback for popping the main file. */ + if (pfile->buffer) + { + _cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0); + + /* Finally, push the next -included file, if any. */ + if (!pfile->buffer->prev) + _cpp_push_next_buffer (pfile); + } } /* Returns the first place in the include chain to start searching for @@ -772,8 +781,7 @@ search_from (pfile, type) if (dlen) { /* We don't guarantee NAME is null-terminated. This saves - allocating and freeing memory, and duplicating it when faking - buffers in cpp_push_buffer. Drop a trailing '/'. */ + allocating and freeing memory. Drop a trailing '/'. */ buffer->dir.name = buffer->inc->name; if (dlen > 1) dlen--; diff --git a/gcc/cpphash.h b/gcc/cpphash.h index d9ebb983f09..a31368396ef 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -171,13 +171,12 @@ struct cpp_buffer cppchar_t read_ahead; /* read ahead character */ cppchar_t extra_char; /* extra read-ahead for long tokens. */ - struct cpp_reader *pfile; /* Owns this buffer. */ struct cpp_buffer *prev; - const unsigned char *buf; /* entire buffer */ + const unsigned char *buf; /* Entire buffer. */ - /* Pointer into the include table. Used for include_next and - to record control macros. */ + /* Pointer into the include table; non-NULL if this is a file + buffer. Used for include_next and to record control macros. */ struct include_file *inc; /* Value of if_stack at start of this file. @@ -214,9 +213,6 @@ struct cpp_buffer token from the enclosing buffer is returned. */ bool return_at_eof; - /* Buffer type. */ - ENUM_BITFIELD (cpp_buffer_type) type : 8; - /* The directory of the this buffer's file. Its NAME member is not allocated, so we don't need to worry about freeing it. */ struct search_path dir; @@ -391,7 +387,8 @@ extern int _cpp_compare_file_date PARAMS ((cpp_reader *, extern void _cpp_report_missing_guards PARAMS ((cpp_reader *)); extern void _cpp_init_includes PARAMS ((cpp_reader *)); extern void _cpp_cleanup_includes PARAMS ((cpp_reader *)); -extern void _cpp_pop_file_buffer PARAMS ((cpp_reader *, cpp_buffer *)); +extern void _cpp_pop_file_buffer PARAMS ((cpp_reader *, + struct include_file *)); /* In cppexp.c */ extern int _cpp_parse_expr PARAMS ((cpp_reader *)); diff --git a/gcc/cppinit.c b/gcc/cppinit.c index b57910cb3e6..9e5fa8e5fd9 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -1546,15 +1546,7 @@ cpp_handle_option (pfile, argc, argv) if (arg[1] == '\0') { - struct pending_option *o1, *o2; - - o1 = pend->directive_head; - while (o1) - { - o2 = o1->next; - free (o1); - o1 = o2; - } + free_chain (pend->directive_head); pend->directive_head = NULL; pend->directive_tail = NULL; } diff --git a/gcc/cpplex.c b/gcc/cpplex.c index a24acabd578..03bd85516cc 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -81,8 +81,8 @@ const struct token_spelling token_spellings [N_TTYPES] = {TTYPE_TABLE }; #define TOKEN_NAME(token) (token_spellings[(token)->type].name) static cppchar_t handle_newline PARAMS ((cpp_reader *, cppchar_t)); -static cppchar_t skip_escaped_newlines PARAMS ((cpp_buffer *, cppchar_t)); -static cppchar_t get_effective_char PARAMS ((cpp_buffer *)); +static cppchar_t skip_escaped_newlines PARAMS ((cpp_reader *, cppchar_t)); +static cppchar_t get_effective_char PARAMS ((cpp_reader *)); static int skip_block_comment PARAMS ((cpp_reader *)); static int skip_line_comment PARAMS ((cpp_reader *)); @@ -95,7 +95,7 @@ static void parse_string PARAMS ((cpp_reader *, cpp_token *, cppchar_t)); static void unterminated PARAMS ((cpp_reader *, int)); static int trigraph_ok PARAMS ((cpp_reader *, cppchar_t)); static void save_comment PARAMS ((cpp_reader *, cpp_token *, const U_CHAR *)); -static void lex_percent PARAMS ((cpp_buffer *, cpp_token *)); +static void lex_percent PARAMS ((cpp_reader *, cpp_token *)); static void lex_dot PARAMS ((cpp_reader *, cpp_token *)); static int name_p PARAMS ((cpp_reader *, const cpp_string *)); static int maybe_read_ucs PARAMS ((cpp_reader *, const unsigned char **, @@ -205,10 +205,12 @@ trigraph_ok (pfile, from_char) been placed in buffer->read_ahead. This routine performs preprocessing stages 1 and 2 of the ISO C standard. */ static cppchar_t -skip_escaped_newlines (buffer, next) - cpp_buffer *buffer; +skip_escaped_newlines (pfile, next) + cpp_reader *pfile; cppchar_t next; { + cpp_buffer *buffer = pfile->buffer; + /* Only do this if we apply stages 1 and 2. */ if (!buffer->from_stage3) { @@ -233,7 +235,7 @@ skip_escaped_newlines (buffer, next) next1 = *buffer->cur++; if (!_cpp_trigraph_map[next1] - || !trigraph_ok (buffer->pfile, next1)) + || !trigraph_ok (pfile, next1)) { RESTORE_STATE (); break; @@ -263,13 +265,12 @@ skip_escaped_newlines (buffer, next) break; } - if (space && !buffer->pfile->state.lexing_comment) - cpp_warning (buffer->pfile, - "backslash and newline separated by space"); + if (space && !pfile->state.lexing_comment) + cpp_warning (pfile, "backslash and newline separated by space"); - next = handle_newline (buffer->pfile, next1); + next = handle_newline (pfile, next1); if (next == EOF) - cpp_pedwarn (buffer->pfile, "backslash-newline at end of file"); + cpp_pedwarn (pfile, "backslash-newline at end of file"); } while (next == '\\' || next == '?'); } @@ -282,9 +283,10 @@ skip_escaped_newlines (buffer, next) an arbitrary string of escaped newlines. The common case of no trigraphs or escaped newlines falls through quickly. */ static cppchar_t -get_effective_char (buffer) - cpp_buffer *buffer; +get_effective_char (pfile) + cpp_reader *pfile; { + cpp_buffer *buffer = pfile->buffer; cppchar_t next = EOF; if (buffer->cur < buffer->rlimit) @@ -296,7 +298,7 @@ get_effective_char (buffer) UCNs, which, depending upon lexer state, we will handle in the future. */ if (next == '?' || next == '\\') - next = skip_escaped_newlines (buffer, next); + next = skip_escaped_newlines (pfile, next); } buffer->read_ahead = next; @@ -322,7 +324,7 @@ skip_block_comment (pfile) /* FIXME: For speed, create a new character class of characters of interest inside block comments. */ if (c == '?' || c == '\\') - c = skip_escaped_newlines (buffer, c); + c = skip_escaped_newlines (pfile, c); /* People like decorating comments with '*', so check for '/' instead for efficiency. */ @@ -383,7 +385,7 @@ skip_line_comment (pfile) c = *buffer->cur++; if (c == '?' || c == '\\') - c = skip_escaped_newlines (buffer, c); + c = skip_escaped_newlines (pfile, c); } while (!is_vspace (c)); @@ -502,7 +504,7 @@ parse_identifier (pfile, c) /* Potential escaped newline? */ if (c != '?' && c != '\\') break; - c = skip_escaped_newlines (buffer, c); + c = skip_escaped_newlines (pfile, c); } while (is_idchar (c)); @@ -584,7 +586,7 @@ parse_number (pfile, number, c, leading_period) /* Potential escaped newline? */ if (c != '?' && c != '\\') break; - c = skip_escaped_newlines (buffer, c); + c = skip_escaped_newlines (pfile, c); } while (is_numchar (c) || c == '.' || VALID_SIGN (c, dest[-1])); @@ -680,7 +682,7 @@ parse_string (pfile, token, terminator) /* Handle trigraphs, escaped newlines etc. */ if (c == '?' || c == '\\') - c = skip_escaped_newlines (buffer, c); + c = skip_escaped_newlines (pfile, c); if (c == terminator && unescaped_terminator_p (pfile, dest)) { @@ -764,16 +766,17 @@ save_comment (pfile, token, from) /* Subroutine of lex_token to handle '%'. A little tricky, since we want to avoid stepping back when lexing %:%X. */ static void -lex_percent (buffer, result) - cpp_buffer *buffer; +lex_percent (pfile, result) + cpp_reader *pfile; cpp_token *result; { + cpp_buffer *buffer= pfile->buffer; cppchar_t c; result->type = CPP_MOD; /* Parsing %:%X could leave an extra character. */ if (buffer->extra_char == EOF) - c = get_effective_char (buffer); + c = get_effective_char (pfile); else { c = buffer->read_ahead = buffer->extra_char; @@ -782,15 +785,15 @@ lex_percent (buffer, result) if (c == '=') ACCEPT_CHAR (CPP_MOD_EQ); - else if (CPP_OPTION (buffer->pfile, digraphs)) + else if (CPP_OPTION (pfile, digraphs)) { if (c == ':') { result->flags |= DIGRAPH; ACCEPT_CHAR (CPP_HASH); - if (get_effective_char (buffer) == '%') + if (get_effective_char (pfile) == '%') { - buffer->extra_char = get_effective_char (buffer); + buffer->extra_char = get_effective_char (pfile); if (buffer->extra_char == ':') { buffer->extra_char = EOF; @@ -822,7 +825,7 @@ lex_dot (pfile, result) /* Parsing ..X could leave an extra character. */ if (buffer->extra_char == EOF) - c = get_effective_char (buffer); + c = get_effective_char (pfile); else { c = buffer->read_ahead = buffer->extra_char; @@ -840,7 +843,7 @@ lex_dot (pfile, result) result->type = CPP_DOT; if (c == '.') { - buffer->extra_char = get_effective_char (buffer); + buffer->extra_char = get_effective_char (pfile); if (buffer->extra_char == '.') { buffer->extra_char = EOF; @@ -914,9 +917,6 @@ _cpp_lex_token (pfile, result) unsigned char stop = buffer->return_at_eof; _cpp_pop_buffer (pfile); - /* Push the next -included file, if any. */ - if (!pfile->buffer->prev) - _cpp_push_next_buffer (pfile); if (!stop) goto next_token; } @@ -963,7 +963,7 @@ _cpp_lex_token (pfile, result) { unsigned int line = pfile->line; - c = skip_escaped_newlines (buffer, c); + c = skip_escaped_newlines (pfile, c); if (line != pfile->line) /* We had at least one escaped newline of some sort, and the next character is in buffer->read_ahead. Update the @@ -1034,7 +1034,7 @@ _cpp_lex_token (pfile, result) /* A potential block or line comment. */ comment_start = buffer->cur; result->type = CPP_DIV; - c = get_effective_char (buffer); + c = get_effective_char (pfile); if (c == '=') ACCEPT_CHAR (CPP_DIV_EQ); if (c != '/' && c != '*') @@ -1091,19 +1091,19 @@ _cpp_lex_token (pfile, result) } result->type = CPP_LESS; - c = get_effective_char (buffer); + c = get_effective_char (pfile); if (c == '=') ACCEPT_CHAR (CPP_LESS_EQ); else if (c == '<') { ACCEPT_CHAR (CPP_LSHIFT); - if (get_effective_char (buffer) == '=') + if (get_effective_char (pfile) == '=') ACCEPT_CHAR (CPP_LSHIFT_EQ); } else if (c == '?' && CPP_OPTION (pfile, cplusplus)) { ACCEPT_CHAR (CPP_MIN); - if (get_effective_char (buffer) == '=') + if (get_effective_char (pfile) == '=') ACCEPT_CHAR (CPP_MIN_EQ); } else if (c == ':' && CPP_OPTION (pfile, digraphs)) @@ -1120,25 +1120,25 @@ _cpp_lex_token (pfile, result) case '>': result->type = CPP_GREATER; - c = get_effective_char (buffer); + c = get_effective_char (pfile); if (c == '=') ACCEPT_CHAR (CPP_GREATER_EQ); else if (c == '>') { ACCEPT_CHAR (CPP_RSHIFT); - if (get_effective_char (buffer) == '=') + if (get_effective_char (pfile) == '=') ACCEPT_CHAR (CPP_RSHIFT_EQ); } else if (c == '?' && CPP_OPTION (pfile, cplusplus)) { ACCEPT_CHAR (CPP_MAX); - if (get_effective_char (buffer) == '=') + if (get_effective_char (pfile) == '=') ACCEPT_CHAR (CPP_MAX_EQ); } break; case '%': - lex_percent (buffer, result); + lex_percent (pfile, result); if (result->type == CPP_HASH) goto do_hash; break; @@ -1149,7 +1149,7 @@ _cpp_lex_token (pfile, result) case '+': result->type = CPP_PLUS; - c = get_effective_char (buffer); + c = get_effective_char (pfile); if (c == '=') ACCEPT_CHAR (CPP_PLUS_EQ); else if (c == '+') @@ -1158,12 +1158,12 @@ _cpp_lex_token (pfile, result) case '-': result->type = CPP_MINUS; - c = get_effective_char (buffer); + c = get_effective_char (pfile); if (c == '>') { ACCEPT_CHAR (CPP_DEREF); if (CPP_OPTION (pfile, cplusplus) - && get_effective_char (buffer) == '*') + && get_effective_char (pfile) == '*') ACCEPT_CHAR (CPP_DEREF_STAR); } else if (c == '=') @@ -1174,25 +1174,25 @@ _cpp_lex_token (pfile, result) case '*': result->type = CPP_MULT; - if (get_effective_char (buffer) == '=') + if (get_effective_char (pfile) == '=') ACCEPT_CHAR (CPP_MULT_EQ); break; case '=': result->type = CPP_EQ; - if (get_effective_char (buffer) == '=') + if (get_effective_char (pfile) == '=') ACCEPT_CHAR (CPP_EQ_EQ); break; case '!': result->type = CPP_NOT; - if (get_effective_char (buffer) == '=') + if (get_effective_char (pfile) == '=') ACCEPT_CHAR (CPP_NOT_EQ); break; case '&': result->type = CPP_AND; - c = get_effective_char (buffer); + c = get_effective_char (pfile); if (c == '=') ACCEPT_CHAR (CPP_AND_EQ); else if (c == '&') @@ -1207,7 +1207,7 @@ _cpp_lex_token (pfile, result) buffer->extra_char = EOF; } else - c = get_effective_char (buffer); + c = get_effective_char (pfile); if (c == '#') { @@ -1247,7 +1247,7 @@ _cpp_lex_token (pfile, result) case '|': result->type = CPP_OR; - c = get_effective_char (buffer); + c = get_effective_char (pfile); if (c == '=') ACCEPT_CHAR (CPP_OR_EQ); else if (c == '|') @@ -1256,13 +1256,13 @@ _cpp_lex_token (pfile, result) case '^': result->type = CPP_XOR; - if (get_effective_char (buffer) == '=') + if (get_effective_char (pfile) == '=') ACCEPT_CHAR (CPP_XOR_EQ); break; case ':': result->type = CPP_COLON; - c = get_effective_char (buffer); + c = get_effective_char (pfile); if (c == ':' && CPP_OPTION (pfile, cplusplus)) ACCEPT_CHAR (CPP_SCOPE); else if (c == '>' && CPP_OPTION (pfile, digraphs)) diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 6b1c11185fc..0a02c15845e 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -83,7 +83,6 @@ static void check_eol PARAMS ((cpp_reader *)); static void start_directive PARAMS ((cpp_reader *)); static void end_directive PARAMS ((cpp_reader *, int)); static void run_directive PARAMS ((cpp_reader *, int, - enum cpp_buffer_type, const char *, size_t)); static int glue_header_name PARAMS ((cpp_reader *, cpp_token *)); static int parse_include PARAMS ((cpp_reader *, cpp_token *)); @@ -394,16 +393,14 @@ _cpp_handle_directive (pfile, indented) /* Directive handler wrapper used by the command line option processor. */ static void -run_directive (pfile, dir_no, type, buf, count) +run_directive (pfile, dir_no, buf, count) cpp_reader *pfile; int dir_no; - enum cpp_buffer_type type; const char *buf; size_t count; { - cpp_buffer *buffer; - - buffer = cpp_push_buffer (pfile, (const U_CHAR *) buf, count, type, 1); + cpp_push_buffer (pfile, (const U_CHAR *) buf, count, + /* from_stage3 */ true, 1); start_directive (pfile); pfile->state.prevent_expansion++; pfile->directive = &dtable[dir_no]; @@ -1160,7 +1157,7 @@ _cpp_do__Pragma (pfile) else { buffer = destringize (&string.val.str, &len); - run_directive (pfile, T_PRAGMA, BUF_PRAGMA, (char *) buffer, len); + run_directive (pfile, T_PRAGMA, (char *) buffer, len); free ((PTR) buffer); pfile->lexer_pos = orig_pos; pfile->line = pfile->lexer_pos.line; @@ -1627,7 +1624,7 @@ cpp_define (pfile, str) buf[count++] = '1'; } - run_directive (pfile, T_DEFINE, BUF_CL_OPTION, buf, count); + run_directive (pfile, T_DEFINE, buf, count); } /* Slight variant of the above for use by initialize_builtins. */ @@ -1636,7 +1633,7 @@ _cpp_define_builtin (pfile, str) cpp_reader *pfile; const char *str; { - run_directive (pfile, T_DEFINE, BUF_BUILTIN, str, strlen (str)); + run_directive (pfile, T_DEFINE, str, strlen (str)); } /* Process MACRO as if it appeared as the body of an #undef. */ @@ -1645,7 +1642,7 @@ cpp_undef (pfile, macro) cpp_reader *pfile; const char *macro; { - run_directive (pfile, T_UNDEF, BUF_CL_OPTION, macro, strlen (macro)); + run_directive (pfile, T_UNDEF, macro, strlen (macro)); } /* Process the string STR as if it appeared as the body of a #assert. */ @@ -1688,7 +1685,7 @@ handle_assertion (pfile, str, type) str = buf; } - run_directive (pfile, type, BUF_CL_OPTION, str, count); + run_directive (pfile, type, str, count); } /* The number of errors for a given reader. */ @@ -1736,11 +1733,11 @@ 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, return_at_eof) +cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof) cpp_reader *pfile; const U_CHAR *buffer; size_t len; - enum cpp_buffer_type type; + int from_stage3; int return_at_eof; { cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer); @@ -1754,14 +1751,8 @@ cpp_push_buffer (pfile, buffer, len, type, return_at_eof) /* No read ahead or extra char initially. */ new->read_ahead = EOF; new->extra_char = EOF; - - /* Preprocessed files, builtins, _Pragma and command line - options don't do trigraph and escaped newline processing. */ - new->from_stage3 = type != BUF_FILE || CPP_OPTION (pfile, preprocessed); - - new->type = type; + new->from_stage3 = from_stage3; new->prev = pfile->buffer; - new->pfile = pfile; new->return_at_eof = return_at_eof; pfile->buffer = new; @@ -1785,26 +1776,20 @@ _cpp_pop_buffer (pfile) cpp_error_with_line (pfile, ifs->pos.line, ifs->pos.col, "unterminated #%s", dtable[ifs->type].name); - /* Update the reader's buffer before _cpp_do_file_change. */ - pfile->buffer = buffer->prev; - - if (buffer->type == BUF_FILE) - { - /* Callbacks are not generated for popping the main file. */ - if (buffer->prev) - _cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0); - - _cpp_pop_file_buffer (pfile, buffer); - } - - obstack_free (&pfile->buffer_ob, buffer); - /* The output line can fall out of sync if we missed the final newline from the previous buffer, for example because of an unterminated comment. Similarly, skipping needs to be cleared in case of a missing #endif. */ pfile->lexer_pos.output_line = pfile->line; pfile->state.skipping = 0; + + /* Update the reader's buffer before _cpp_do_file_change. */ + pfile->buffer = buffer->prev; + + if (buffer->inc) + _cpp_pop_file_buffer (pfile, buffer->inc); + + obstack_free (&pfile->buffer_ob, buffer); } void diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 9fc058d50af..8c495736aa9 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -405,10 +405,6 @@ struct cpp_callbacks /* Name under which this program was invoked. */ extern const char *progname; -/* Where does this buffer come from? A source file, a builtin macro, - a command-line option, or a _Pragma operator. */ -enum cpp_buffer_type {BUF_FILE, BUF_BUILTIN, BUF_CL_OPTION, BUF_PRAGMA}; - /* The structure of a node in the hash table. The hash table has entries for all identifiers: either macros defined by #define commands (type NT_MACRO), assertions created with #assert @@ -541,7 +537,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, int)); + int, int)); extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int)); /* N.B. The error-message-printer prototypes have not been nicely diff --git a/gcc/fix-header.c b/gcc/fix-header.c index 2d7f8d4e59e..068cc692c6e 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, 1); + /* from_stage3 */ true, 1); for (;;) { cpp_token t; -- 2.30.2