gcc/gcc/cppmain.c

460 lines
13 KiB
C
Raw Normal View History

/* Preprocess only, using cpplib.
Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
1995-03-16 22:59:07 +01:00
Written by Per Bothner, 1994-95.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
1995-06-15 13:33:25 +02:00
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1995-03-16 22:59:07 +01:00
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
#include "config.h"
#include "system.h"
#include "cpplib.h"
#include "cpphash.h"
1995-03-16 22:59:07 +01:00
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
/* Encapsulates state used to convert the stream of tokens coming from
cpp_get_token back into a text file. */
struct printer
{
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
FILE *outf; /* Stream to write to. */
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
2001-08-11 09:33:39 +02:00
const struct line_map *map; /* Logical to physical line mappings. */
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
const cpp_token *prev; /* Previous token. */
const cpp_token *source; /* Source token for spacing. */
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
unsigned int line; /* Line currently being written. */
unsigned char printed; /* Nonzero if something output at line. */
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
};
1995-03-16 22:59:07 +01:00
static void setup_callbacks PARAMS ((cpp_reader *));
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
/* General output routines. */
static void scan_translation_unit PARAMS ((cpp_reader *));
static void scan_translation_unit_trad PARAMS ((cpp_reader *));
static void account_for_newlines PARAMS ((const uchar *, size_t));
static int dump_macro PARAMS ((cpp_reader *, cpp_hashnode *, void *));
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
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
2001-08-11 09:33:39 +02:00
static void print_line PARAMS ((const struct line_map *, unsigned int,
const char *));
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
2001-08-11 09:33:39 +02:00
static void maybe_print_line PARAMS ((const struct line_map *, unsigned int));
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
/* Callback routines for the parser. Most of these are active only
in specific modes. */
static void cb_line_change PARAMS ((cpp_reader *, const cpp_token *, int));
static void cb_define PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
static void cb_undef PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
static void cb_include PARAMS ((cpp_reader *, unsigned int,
const unsigned char *, const cpp_token *));
static void cb_ident PARAMS ((cpp_reader *, unsigned int,
const cpp_string *));
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
2001-08-11 09:33:39 +02:00
static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
static void cb_def_pragma PARAMS ((cpp_reader *, unsigned int));
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
static cpp_options *options; /* Options of pfile. */
static struct printer print;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
/* Preprocess and output. */
void
cpp_preprocess_file (pfile)
cpp_reader *pfile;
1995-03-16 22:59:07 +01:00
{
options = cpp_get_options (pfile);
/* Let preprocessor know if it's only preprocessing. It would be
nice to lose this somehow. */
options->preprocess_only = 1;
/* Initialize the printer structure. Setting print.line to -1 here
is a trick to guarantee that the first token of the file will
cause a linemarker to be output by maybe_print_line. */
print.line = (unsigned int) -1;
print.printed = 0;
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
print.prev = 0;
print.map = 0;
/* Open the output now. We must do so even if no_output is on,
because there may be other output than from the actual
preprocessing (e.g. from -dM). */
if (options->out_fname[0] == '\0')
print.outf = stdout;
else
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
{
print.outf = fopen (options->out_fname, "w");
if (print.outf == NULL)
{
cpperror.c (print_location): Don't print include chain if line == 0. * cpperror.c (print_location): Don't print include chain if line == 0. (cpp_begin_message): Update to use DL_ macros. (cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_notice, cpp_notice_from_errno): Remove. (cpp_error, cpp_error_with_line): Update to take a diagnostic level. (cpp_errno): New. * cppexp.c (CPP_ICE): Remove. (SYNTAX_ERROR, SYNTAX_ERROR2, parse_number, parse_defined, lex, integer_overflow, _cpp_parse_expr): Update. * cppfiles.c (read_include_file, find_include_file, handle_missing_header, _cpp_read_file, remap_filename): Update. * cpphash.h (enum error_type): Remove. (_cpp_begin_message): Update. * cppinit.c (append_include_chain, remove_dup_dirs, output_deps, cpp_handle_option, cpp_post_options): Update. * cpplex.c (trigraph_p, skip_escaped_newlines, skip_block_comment, skip_whitespace, parse_identifier, parse_slow, parse_string, _cpp_lex_direct, cpp_spell_token, maybe_read_ucs, cpp_parse_escape, cpp_interpret_charconst): Update. * cpplib.c (check_eol, directive_diagnostics, _cpp_handle_directive, lex_macro_node, do_undef, glue_header_name, parse_include, do_include_common, read_flag, do_line, do_linemarker, do_ident, cpp_register_pragma, do_pragma_once, do_pragma_system_header, do_pragma_poison, do_pragma_dependency, _cpp_do__Pragma, do_else, do_elif, do_endif, parse_answer, parse_assertion, do_assert, _cpp_pop_buffer, do_diagnostic): Update. * cpplib.h (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN, DL_ERROR, DL_FATAL, DL_ICE, DL_EXTRACT, DL_WARNING_P): New. (cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_notice, cpp_notice_from_errno): Remove. (cpp_error, cpp_error_with_line): Update to take a diagnostic level. (cpp_errno): New. * cppmacro.c (builtin_macro, stringify_arg, paste_all_tokens, collect_args, enter_macro_context, save_parameter, parse_params, _cpp_create_definition, check_trad_stringification, cpp_macro_definition): Update. * cppmain.c (cpp_preprocess_file): Update. * fix-header.c (read_scan_file): Update. From-SVN: r52302
2002-04-14 20:42:47 +02:00
cpp_errno (pfile, DL_ERROR, options->out_fname);
return;
}
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
}
setup_callbacks (pfile);
c-common.c: Include c-lex.h. * c-common.c: Include c-lex.h. (c_common_lang_init): Change prototype. Call init_c_lex and init_pragma from here. * c-common.h (c_common_lang_init): Change prototype. * c-decl.c (init_decl_processing): Rename. Call c_parse_init. * c-lang.c (c_init): Change prototype. Update. (c_init_options): Update. * c-lex.c (cpp_filename): Remove. (init_c_lex): Update. Read the main file, and get the original file name. (yyparse): Finish the command line options. * c-parse.in (c_parse_init): Call init_reswords here. (init_parse): Remove. * c-tree.h (c_init_decl_processing): New. * cpphash.c (_cpp_init_hashtable): After initializing the hash table, populate it. * cppinit.c (read_original_filename, cpp_finish_options): New. (cpp_create_reader): New prototype. Defer hash table initialization. (cpp_start_read): Rename cpp_read_main_file. Initialize the hash table. Get the original filename. * cpplib.h (cpp_create_reader): Update. (cpp_start_read): Remove. (cpp_read_main_file, cpp_finish_options): New. * cppmain.c (main, do_preprocessing): Update. * langhooks.h (struct langhooks): Update init prototype. * toplev.c (general_init, parse_options_and_default_flags, process_options, lang_indpendent_init, lang_dependent_init, init_asm_output): New; perform the bulk of initialization. (compile_file): Move most of initialization to above functions. (debug_hooks): Initialize statically. (set_Wunused): Relocate. (toplev_main): Move most of initialization to other init functions. Have a clear logic flow. * tree.h (init_parse, init_decl_processing): Remove. ada: * misc.c (gnat_init): Change prototype. Include the functionality of the old init_parse and init_decl_processing. (gnat_init_decl_processing): New prototype. (init_parse): Remove. * utils.c (init_decl_processing): Rename gnat_init_decl_processing. cp: * cp-tree.h (init_reswords, cxx_init_decl_processing): New. (cxx_init): Update prototype. * decl.c (init_decl_processing): Rename. Move null node init to its creation time. * lex.c (cxx_init_options): Update. (cxx_init): Combine with old init_parse; also call cxx_init_decl_processing. f: * com.c (ffecom_init_decl_processing): Renamed from init_decl_processing. (init_parse): Move contents to ffe_init. (ffe_init): Update prototype. java: * decl.c (init_decl_processing): Rename java_init_decl_processing. * java-tree.h: New prototype. * lang.c (java_init): Update prototype. Combine with old init_parse. objc: * objc-act.c (objc_init): Update prototype, combine with old init_parse. (objc_init_options): Update. From-SVN: r47046
2001-11-15 11:01:10 +01:00
if (cpp_read_main_file (pfile, options->in_fname, NULL))
{
c-common.c: Include c-lex.h. * c-common.c: Include c-lex.h. (c_common_lang_init): Change prototype. Call init_c_lex and init_pragma from here. * c-common.h (c_common_lang_init): Change prototype. * c-decl.c (init_decl_processing): Rename. Call c_parse_init. * c-lang.c (c_init): Change prototype. Update. (c_init_options): Update. * c-lex.c (cpp_filename): Remove. (init_c_lex): Update. Read the main file, and get the original file name. (yyparse): Finish the command line options. * c-parse.in (c_parse_init): Call init_reswords here. (init_parse): Remove. * c-tree.h (c_init_decl_processing): New. * cpphash.c (_cpp_init_hashtable): After initializing the hash table, populate it. * cppinit.c (read_original_filename, cpp_finish_options): New. (cpp_create_reader): New prototype. Defer hash table initialization. (cpp_start_read): Rename cpp_read_main_file. Initialize the hash table. Get the original filename. * cpplib.h (cpp_create_reader): Update. (cpp_start_read): Remove. (cpp_read_main_file, cpp_finish_options): New. * cppmain.c (main, do_preprocessing): Update. * langhooks.h (struct langhooks): Update init prototype. * toplev.c (general_init, parse_options_and_default_flags, process_options, lang_indpendent_init, lang_dependent_init, init_asm_output): New; perform the bulk of initialization. (compile_file): Move most of initialization to above functions. (debug_hooks): Initialize statically. (set_Wunused): Relocate. (toplev_main): Move most of initialization to other init functions. Have a clear logic flow. * tree.h (init_parse, init_decl_processing): Remove. ada: * misc.c (gnat_init): Change prototype. Include the functionality of the old init_parse and init_decl_processing. (gnat_init_decl_processing): New prototype. (init_parse): Remove. * utils.c (init_decl_processing): Rename gnat_init_decl_processing. cp: * cp-tree.h (init_reswords, cxx_init_decl_processing): New. (cxx_init): Update prototype. * decl.c (init_decl_processing): Rename. Move null node init to its creation time. * lex.c (cxx_init_options): Update. (cxx_init): Combine with old init_parse; also call cxx_init_decl_processing. f: * com.c (ffecom_init_decl_processing): Renamed from init_decl_processing. (init_parse): Move contents to ffe_init. (ffe_init): Update prototype. java: * decl.c (init_decl_processing): Rename java_init_decl_processing. * java-tree.h: New prototype. * lang.c (java_init): Update prototype. Combine with old init_parse. objc: * objc-act.c (objc_init): Update prototype, combine with old init_parse. (objc_init_options): Update. From-SVN: r47046
2001-11-15 11:01:10 +01:00
cpp_finish_options (pfile);
/* A successful cpp_read_main_file guarantees that we can call
cpp_scan_nooutput or cpp_get_token next. */
if (options->no_output)
cpp_scan_nooutput (pfile);
else if (options->traditional)
scan_translation_unit_trad (pfile);
else
scan_translation_unit (pfile);
/* -dM command line option. Should this be in cpp_finish? */
if (options->dump_macros == dump_only)
cpp_forall_identifiers (pfile, dump_macro, NULL);
}
/* Flush any pending output. */
if (print.printed)
putc ('\n', print.outf);
/* Don't close stdout (dependencies have yet to be output). */
if (print.outf != stdout)
{
if (ferror (print.outf) || fclose (print.outf))
cpperror.c (print_location): Don't print include chain if line == 0. * cpperror.c (print_location): Don't print include chain if line == 0. (cpp_begin_message): Update to use DL_ macros. (cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_notice, cpp_notice_from_errno): Remove. (cpp_error, cpp_error_with_line): Update to take a diagnostic level. (cpp_errno): New. * cppexp.c (CPP_ICE): Remove. (SYNTAX_ERROR, SYNTAX_ERROR2, parse_number, parse_defined, lex, integer_overflow, _cpp_parse_expr): Update. * cppfiles.c (read_include_file, find_include_file, handle_missing_header, _cpp_read_file, remap_filename): Update. * cpphash.h (enum error_type): Remove. (_cpp_begin_message): Update. * cppinit.c (append_include_chain, remove_dup_dirs, output_deps, cpp_handle_option, cpp_post_options): Update. * cpplex.c (trigraph_p, skip_escaped_newlines, skip_block_comment, skip_whitespace, parse_identifier, parse_slow, parse_string, _cpp_lex_direct, cpp_spell_token, maybe_read_ucs, cpp_parse_escape, cpp_interpret_charconst): Update. * cpplib.c (check_eol, directive_diagnostics, _cpp_handle_directive, lex_macro_node, do_undef, glue_header_name, parse_include, do_include_common, read_flag, do_line, do_linemarker, do_ident, cpp_register_pragma, do_pragma_once, do_pragma_system_header, do_pragma_poison, do_pragma_dependency, _cpp_do__Pragma, do_else, do_elif, do_endif, parse_answer, parse_assertion, do_assert, _cpp_pop_buffer, do_diagnostic): Update. * cpplib.h (DL_WARNING, DL_WARNING_SYSHDR, DL_PEDWARN, DL_ERROR, DL_FATAL, DL_ICE, DL_EXTRACT, DL_WARNING_P): New. (cpp_ice, cpp_fatal, cpp_error_from_errno, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_notice, cpp_notice_from_errno): Remove. (cpp_error, cpp_error_with_line): Update to take a diagnostic level. (cpp_errno): New. * cppmacro.c (builtin_macro, stringify_arg, paste_all_tokens, collect_args, enter_macro_context, save_parameter, parse_params, _cpp_create_definition, check_trad_stringification, cpp_macro_definition): Update. * cppmain.c (cpp_preprocess_file): Update. * fix-header.c (read_scan_file): Update. From-SVN: r52302
2002-04-14 20:42:47 +02:00
cpp_errno (pfile, DL_ERROR, options->out_fname);
}
}
/* Set up the callbacks as appropriate. */
static void
setup_callbacks (pfile)
cpp_reader *pfile;
{
cpp_callbacks *cb = cpp_get_callbacks (pfile);
if (! options->no_output)
{
cb->line_change = cb_line_change;
/* Don't emit #pragma or #ident directives if we are processing
assembly language; the assembler may choke on them. */
if (options->lang != CLK_ASM)
{
cb->ident = cb_ident;
cb->def_pragma = cb_def_pragma;
}
if (! options->no_line_commands)
cb->file_change = cb_file_change;
}
if (options->dump_includes)
cb->include = cb_include;
if (options->dump_macros == dump_names
|| options->dump_macros == dump_definitions)
{
cb->define = cb_define;
cb->undef = cb_undef;
}
}
/* Writes out the preprocessed file, handling spacing and paste
avoidance issues. */
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
static void
scan_translation_unit (pfile)
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
cpp_reader *pfile;
{
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
bool avoid_paste = false;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
print.source = NULL;
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
for (;;)
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
{
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
const cpp_token *token = cpp_get_token (pfile);
if (token->type == CPP_PADDING)
{
avoid_paste = true;
if (print.source == NULL
|| (!(print.source->flags & PREV_WHITE)
&& token->val.source == NULL))
print.source = token->val.source;
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
continue;
}
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
if (token->type == CPP_EOF)
break;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
/* Subtle logic to output a space if and only if necessary. */
if (avoid_paste)
{
if (print.source == NULL)
print.source = token;
if (print.source->flags & PREV_WHITE
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
|| (print.prev && cpp_avoid_paste (pfile, print.prev, token))
|| (print.prev == NULL && token->type == CPP_HASH))
putc (' ', print.outf);
}
else if (token->flags & PREV_WHITE)
putc (' ', print.outf);
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
avoid_paste = false;
print.source = NULL;
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
print.prev = token;
cpp_output_token (token, print.outf);
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
if (token->type == CPP_COMMENT)
account_for_newlines (token->val.str.text, token->val.str.len);
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
}
}
/* Adjust print.line for newlines embedded in output. */
static void
account_for_newlines (str, len)
const uchar *str;
size_t len;
{
while (len--)
if (*str++ == '\n')
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line++;
}
/* Writes out a traditionally preprocessed file. */
static void
scan_translation_unit_trad (pfile)
cpp_reader *pfile;
{
for (;;)
{
size_t len;
if (!_cpp_read_logical_line_trad (pfile))
break;
len = pfile->out.cur - pfile->out.base;
maybe_print_line (print.map, pfile->out.first_line);
fwrite (pfile->out.base, 1, len, print.outf);
print.printed = 1;
if (!CPP_OPTION (pfile, discard_comments))
account_for_newlines (pfile->out.base, len);
}
}
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
/* If the token read on logical line LINE needs to be output on a
different line to the current one, output the required newlines or
a line marker, and return 1. Otherwise return 0. */
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
static void
maybe_print_line (map, line)
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
2001-08-11 09:33:39 +02:00
const struct line_map *map;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
unsigned int line;
{
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
/* End the previous line of text. */
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
if (print.printed)
{
putc ('\n', print.outf);
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line++;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
print.printed = 0;
}
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
if (line >= print.line && line < print.line + 8)
{
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
while (line > print.line)
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
{
putc ('\n', print.outf);
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line++;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
}
}
else
print_line (map, line, "");
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
}
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
2001-08-11 09:33:39 +02:00
/* Output a line marker for logical line LINE. Special flags are "1"
or "2" indicating entering or leaving a file. */
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
static void
print_line (map, line, special_flags)
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
2001-08-11 09:33:39 +02:00
const struct line_map *map;
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
unsigned int line;
const char *special_flags;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
{
/* End any previous line of text. */
if (print.printed)
putc ('\n', print.outf);
print.printed = 0;
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line = line;
if (! options->no_line_commands)
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
2001-08-11 09:33:39 +02:00
{
size_t to_file_len = strlen (map->to_file);
unsigned char *to_file_quoted = alloca (to_file_len * 4 + 1);
unsigned char *p;
/* cpp_quote_string does not nul-terminate, so we have to do it
ourselves. */
p = cpp_quote_string (to_file_quoted,
(unsigned char *)map->to_file, to_file_len);
*p = '\0';
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
2001-08-11 09:33:39 +02:00
fprintf (print.outf, "# %u \"%s\"%s",
SOURCE_LINE (map, print.line), to_file_quoted, special_flags);
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
2001-08-11 09:33:39 +02:00
if (map->sysp == 2)
fputs (" 3 4", print.outf);
else if (map->sysp == 1)
fputs (" 3", print.outf);
putc ('\n', print.outf);
}
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
}
/* Called when a line of output is started. TOKEN is the first token
of the line, and at end of file will be CPP_EOF. */
static void
cb_line_change (pfile, token, parsing_args)
cpp_reader *pfile ATTRIBUTE_UNUSED;
const cpp_token *token;
int parsing_args;
{
if (token->type == CPP_EOF || parsing_args)
return;
maybe_print_line (print.map, token->line);
c-lex.c (cb_def_pragma): Update. * c-lex.c (cb_def_pragma): Update. (c_lex): Update, and skip padding. * cppexp.c (lex, parse_defined): Update, remove unused variable. * cpphash.h (struct toklist): Delete. (union utoken): New. (struct cpp_context): Update. (struct cpp_reader): New members eof, avoid_paste. (_cpp_temp_token): New. * cppinit.c (cpp_create_reader): Update. * cpplex.c (_cpp_temp_token): New. (_cpp_lex_direct): Add PREV_WHITE when parsing args. (cpp_output_token): Don't print leading whitespace. (cpp_output_line): Update. * cpplib.c (glue_header_name, parse_include, get__Pragma_string, do_include_common, do_line, do_ident, do_pragma, do_pragma_dependency, _cpp_do__Pragma, parse_answer, parse_assertion): Update. (get_token_no_padding): New. * cpplib.h (CPP_PADDING): New. (AVOID_LPASTE): Delete. (struct cpp_token): New union member source. (cpp_get_token): Update. * cppmacro.c (macro_arg): Convert to use pointers to const tokens. (builtin_macro, paste_all_tokens, paste_tokens, funlike_invocation_p, replace_args, quote_string, stringify_arg, parse_arg, next_context, enter_macro_context, expand_arg, _cpp_pop_context, cpp_scan_nooutput, _cpp_backup_tokens, _cpp_create_definition): Update. (push_arg_context): Delete. (padding_token, push_token_context, push_ptoken_context): New. (make_string_token, make_number_token): Update, rename. (cpp_get_token): Update to handle tokens as pointers to const, and insert padding appropriately. * cppmain.c (struct printer): New member prev. (check_multiline_token): Constify. (do_preprocessing, cb_line_change): Update. (scan_translation_unit): Update to handle spacing. * scan-decls.c (get_a_token): New. (skip_to_closing_brace, scan_decls): Update. * fix-header.c (read_scan_file): Update. * doc/cpp.texi: Update. * gcc.dg/cpp/macro10.c: New test. * gcc.dg/cpp/strify3.c: New test. * gcc.dg/cpp/spacing1.c: Add tests. * gcc.dg/cpp/19990703-1.c: Remove bogus test. * gcc.dg/cpp/20000625-2.c: Fudge to pass. From-SVN: r45793
2001-09-25 00:53:12 +02:00
print.prev = 0;
print.source = 0;
/* Supply enough spaces to put this token in its original column,
one space per column greater than 2, since scan_translation_unit
will provide a space if PREV_WHITE. Don't bother trying to
reconstruct tabs; we can't get it right in general, and nothing
ought to care. Some things do care; the fault lies with them. */
if (!CPP_OPTION (pfile, traditional))
{
print.printed = 1;
if (token->col > 2)
{
unsigned int spaces = token->col - 2;
while (spaces--)
putc (' ', print.outf);
}
}
}
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
static void
cb_ident (pfile, line, str)
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
cpp_reader *pfile ATTRIBUTE_UNUSED;
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
unsigned int line;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
const cpp_string * str;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
{
maybe_print_line (print.map, line);
fprintf (print.outf, "#ident \"%s\"\n", str->text);
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line++;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
}
static void
cb_define (pfile, line, node)
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
cpp_reader *pfile;
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
unsigned int line;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
cpp_hashnode *node;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
{
maybe_print_line (print.map, line);
fputs ("#define ", print.outf);
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
/* -dD command line option. */
if (options->dump_macros == dump_definitions)
fputs ((const char *) cpp_macro_definition (pfile, node), print.outf);
else
fputs ((const char *) NODE_NAME (node), print.outf);
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
putc ('\n', print.outf);
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line++;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
}
static void
cb_undef (pfile, line, node)
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
cpp_reader *pfile ATTRIBUTE_UNUSED;
unsigned int line;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
cpp_hashnode *node;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
{
maybe_print_line (print.map, line);
fprintf (print.outf, "#undef %s\n", NODE_NAME (node));
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line++;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
}
static void
cb_include (pfile, line, dir, header)
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
cpp_reader *pfile;
unsigned int line;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
const unsigned char *dir;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
const cpp_token *header;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
{
maybe_print_line (print.map, line);
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
fprintf (print.outf, "#%s %s\n", dir, cpp_token_as_text (pfile, header));
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line++;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
}
/* The file name, line number or system header flags have changed, as
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
2001-08-11 09:33:39 +02:00
described in MAP. From this point on, the old print.map might be
pointing to freed memory, and so must not be dereferenced. */
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
static void
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
2001-08-11 09:33:39 +02:00
cb_file_change (pfile, map)
cpp_reader *pfile ATTRIBUTE_UNUSED;
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
2001-08-11 09:33:39 +02:00
const struct line_map *map;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
{
const char *flags = "";
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
/* First time? */
if (print.map == NULL)
{
/* Avoid printing foo.i when the main file is foo.c. */
if (!options->preprocessed)
print_line (map, map->from_line, flags);
}
else
{
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
2001-08-11 09:33:39 +02:00
/* Bring current file to correct line when entering a new file. */
if (map->reason == LC_ENTER)
maybe_print_line (map - 1, map->from_line - 1);
if (map->reason == LC_ENTER)
flags = " 1";
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
2001-08-11 09:33:39 +02:00
else if (map->reason == LC_LEAVE)
flags = " 2";
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
2001-08-11 09:33:39 +02:00
print_line (map, map->from_line, flags);
}
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
2001-08-11 09:33:39 +02:00
print.map = map;
}
/* Copy a #pragma directive to the preprocessed output. */
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
static void
cb_def_pragma (pfile, line)
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
cpp_reader *pfile;
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
unsigned int line;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
{
maybe_print_line (print.map, line);
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
fputs ("#pragma ", print.outf);
cpp_output_line (pfile, print.outf);
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line++;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
}
/* Dump out the hash table. */
static int
dump_macro (pfile, node, v)
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
cpp_reader *pfile;
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
cpp_hashnode *node;
void *v ATTRIBUTE_UNUSED;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
{
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
{
fputs ("#define ", print.outf);
New macro expander. 2000-10-28 Neil Booth <neilb@earthling.net> New macro expander. * cpplib.c (struct answer): New. (struct if_stack): Use cpp_lexer_pos rather than line and col. Rename cmacro mi_cmacro. (struct directive, KANDR, STDC89, EXTENSION, COND, IF_COND, INCL, IN_I): New directive and flags. (skip_rest_of_line, check_eol, run_directive, glue_header_name, parse_answer, parse_assertion, find_answer): New functions. (parse_ifdef, detect_if_not_defined, validate_else): Remove. (lex_macro_node): New function to replace parse_ifdef and get_define_node. (_cpp_handle_directive): New function, combines _cpp_check_directive and _cpp_check_linemarker. (do_define, do_undef, parse_include, do_include, do_import, do_include_next, read_line_number, do_line, do_ident, do_pragma, do_pragma_once, do_pragma_poison, do_pragma_dependency): Update for new token getting interface. (do_ifdef, do_ifndef, do_if, do_else, do_endif, push_conditional) : Update for new multiple-include optimisation technique. (do_elif): Don't forget to invalidate controlling macros. (unwind_if_stack, cpp_defined, cpp_push_buffer, cpp_pop_buffer): Update. (parse_assertion, parse_answer, find_answer, _cpp_test_assertion): Functions to handle assertions with the new token interface. (do_assert, do_unassert): Use them. (cpp_define, _cpp_define_builtin, cpp_undef, cpp_assert, cpp_unassert): Use run_directive. (_cpp_init_stacks): Register directive names. Don't register special nodes. * cpperror.c (print_containing_files, _cpp_begin_message): Update to new position recording regime. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Update for _cpp_begin_message changes. (cpp_type2name): Move to cpplex.c. * cppexp.c (parse_charconst): spec_nodes is no longer a pointer. (parse_defined): Update to handle new multiple include optimisation method. Remove poisoned identifier warning. (parse_assertion, TYPE_NAME): Delete. (lex): Update for multiple include optimisation, removal of CPP_DEFINED, to use _cpp_test_assertion for assertions and cpp_token_as_text. (_cpp_parse_expr): Update for MI optimisation, and to use op_as_text. (op_as_text): New function, to wrap cpp_token_as_text. * cppfiles.c (stack_include_file, _cpp_pop_file_buffer): Update for MI optimisation. (_cpp_execute_include): Take a token rather than 3 arguments. Fix segfault on diagnostic. (_cpp_compare_file_date): Take a token rather than 3 args. (cpp_read_file): Work correctly for zero-length files. * cpphash.c (_cpp_init_macros, _cpp_cleanup_macros): Rename _cpp_init_hashtable and _cpp_cleanup_hashtable. (cpp_lookup): Place identifiers at front of identifier pool for _cpp_lookup_with_hash. (_cpp_lookup_with_hash): Require identifiers to be at the front of the identifier pool. Commit the memory if not already in the hash table. * cppinit.c (cpp_reader_init): Move cpp_init_completed test to top. Initialise various members of cpp_reader, memory pools, and the special nodes. (cpp_printer_init): Delete. (cpp_cleanup): Update. (struct builtin, builtin_array, initialize_builtins): Update for new hashnode definition and builtin handling. (cpp_start_read, cpp_finish): Don't take or initialise a printer. Update. * cpplib.h (cpp_printer, cpp_toklist, CPP_DEFINED, BOL, PASTED, VAR_ARGS, BEG_OF_FILE, IN_DIRECTIVE, KNOWN_DIRECTIVE, T_VOID, T_SPECLINE, T_DATE, T_FILE, T_BASE_FILE, T_INCLUDE_LEVEL, T_TIME, T_STDC, T_OPERATOR, T_POISON, T_MACRO, T_ASSERTION): Delete. (struct cpp_pool, struct cpp_macro, struct cpp_lexer_pos, struct cpp_lookahead, CPP_DHASH, enum mi_state, enum mi_ind, NO_EXPAND, VARARGS_FIRST, struct cpp_token_with_pos, struct toklist, struct cpp_context, struct specnodes, TOKEN_LOOKAHEAD, TOKEN_BUFFSIZE, NODE_OPERATOR, NODE_POISONED, NODE_BUILTIN, NODE_DIAGNOSTIC, NT_VOID, NT_MACRO, NT_ASSERTION, enum builtin_type, cpp_can_paste): New. (struct cpp_token): Delete line and col members. (struct cpp_buffer): New member output_lineno. (struct lexer_state): Delete indented, in_lex_line, seen_dot. Add va_args_ok, poisoned_ok, prevent_expansion, parsing_args. (struct cpp_reader): New members lexer_pos, macro_pos, directive_pos, ident_pool, temp_string_pool, macro_pool, argument_pool, string_pool, base_context, context, directive, mi_state, mi_if_not_defined, mi_lexed, mi_cmacro, mi_ind_cmacro, la_read, la_write, la_unused, mlstring_pos, macro_buffer, macro_buffer_len. Delete members mls_line, mls_column, token_list, potential_control_macro, temp_tokens, temp_cap, temp_alloced, temp_used, first_directive_token, context_cap, cur_context, no_expand_level, paste_level, contexts, args, save_parameter_spellings, need_newline, . Change type of date, time and spec_nodes members. Change prototypes for include and ident callbacks. (struct cpp_hashnode): Change type of name. Remove union members expansion and code. Add members macro, operator and builtin. (cpp_token_len, cpp_token_as_text, cpp_spell_token, cpp_start_read, cpp_finish, cpp_avoid_paste, cpp_get_token, cpp_get_line, cpp_get_output_line, cpp_macro_definition, cpp_start_lookahead, cpp_stop_lookahead): New prototypes. (cpp_printer_init, cpp_dump_definition): Delete prototypes. (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move from cpphash.h. * cpphash.h (U_CHAR, U, ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr, ufputs): Move to cpplib.h. (enum spell_type, struct token_spelling, _cpp_token_spellings, TOKEN_SPELL, TOKEN_NAME, struct answer, FREE_ANSWER, KANDR, STDC89, EXTENSION, COND, EXPAND, INCL, COMMENTS, IN_I, struct directive, directive_handler, struct spec_nodes, _cpp_digraph_spellings, _cpp_free_temp_tokens, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_init_toklist, _cpp_clear_toklist, _cpp_expand_token_space, _cpp_expand_name_space, _cpp_equiv_tokens, _cpp_equiv_toklists, _cpp_process_directive, _cpp_run_directive, _cpp_get_line, _cpp_get_raw_token, _cpp_glue_header_name, _cpp_can_paste, _cpp_check_directive, _cpp_check_linemarker, _cpp_parse_assertion, _cpp_find_answer): Delete. (VALID_SIGN, ALIGN, POOL_FRONT, POOL_LIMIT, POOL_BASE, POOL_SIZE, POOL_USED, POOL_COMMIT, struct cpp_chunk, _cpp_lex_token, _cpp_init_pool, _cpp_free_pool, _cpp_pool_reserve, _cpp_pool_alloc, _cpp_next_chunk, _cpp_lock_pool, _cpp_unlock_pool, _cpp_test_assertion, _cpp_handle_directive, DSC): New. (struct include_file): New member defined. (DO_NOT_REREAD, _cpp_begin_message, _cpp_execute_include, _cpp_compare_file_date): Update. (_cpp_pop_context, _cpp_get_token, _cpp_free_lookaheads, _cpp_push_token): New. (_cpp_init_macros, _cpp_cleanup_macros): Rename to _cpp_init_hashtable, _cpp_cleanup_hashtable. * Makefile.in: Remove cppoutput.c. * cppoutput.c: Delete * fixheader.c (read_scan_file): Update for new cpp_get_token prototype. (recognized_function): New argument LINE. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new cpp_get_token prototype. * scan.h (recognized_function): Update prototype. * po/POTFILES.in: Remove cppoutput.c. From-SVN: r37098
2000-10-28 19:59:06 +02:00
fputs ((const char *) cpp_macro_definition (pfile, node), print.outf);
putc ('\n', print.outf);
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used) PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
2001-08-05 19:31:25 +02:00
print.line++;
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. * cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-08-02 03:13:45 +02:00
}
return 1;
}