aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpphash.c
AgeCommit message (Collapse)AuthorFilesLines
2001-01-28cpphash.c (_cpp_cleanup_hashtable, [...]): Don't set fe_value.Neil Booth1-5/+1
* cpphash.c (_cpp_cleanup_hashtable, _cpp_lookup_with_hash) : Don't set fe_value. * cpplib.h (AVOID_LPASTE): New flag. (struct cpp_hashnode): Remove fe_value. * cpplex.c (cpp_avoid_paste): Don't paste '.' with a number. * cppmacro.c (builtin_macro): Don't set flags here. (replace_args): Set AVOID_LPASTE flag on first token of an argument, and the token following it. (cpp_get_token): Set AVOID_LPASTE flag on first token of a macro expansion, and on the token following it. Do it for builtins too. * cppmain.c (scan_buffer): Avoid pasting only flagged tokens. From-SVN: r39318
2000-11-09cpphash.c: Move cpp_defined here from cpplib.c.Neil Booth1-0/+13
* cpphash.c: Move cpp_defined here from cpplib.c. * cpplib.c: Update comments, move cpp_defined to cpphash.c. * cpplex.c (_cpp_lex_token): Don't leave the lexer at EOL. * cppmacro.c (cpp_get_token): Update comments, no need now to catch the CPP_EOF meaning EOL case. From-SVN: r37345
2000-10-29cpphash.c (cpp_forall_identifiers): Add context variable for callback routine.Geoff Keating1-3/+4
* cpphash.c (cpp_forall_identifiers): Add context variable for callback routine. * cppmain.c (dump_macro): Update to match cpp_forall_identifiers change. (main): Call cpp_forall_identifiers with null context. * cpplib.h (cpp_forall_identifiers): Update prototype. * cppmain.c: Make `parse_in' and `print' static. From-SVN: r37119
2000-10-28New macro expander.Neil Booth1-40/+44
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-09-18cpphash.h (HASHSTEP): Take character rather than pointer to character.Neil Booth1-1/+1
* cpphash.h (HASHSTEP): Take character rather than pointer to character. (_cpp_check_directive, _cpp_check_linemarker): Update prototypes. * cpphash.c (cpp_loookup): Update for new HASHSTEP. * cpplex.c (auto_expand_name_space, trigraph_replace, backslash_start, handle_newline, parse_name, INIT_TOKEN_STR, IMMED_TOKEN, PREV_TOKEN_TYPE, PUSH_TOKEN, REVISE_TOKEN, BACKUP_TOKEN, BACKUP_TRIGRAPH, MIGHT_BE_DIRECTIVE, KNOWN_DIRECTIVE): Delete. (handle_newline, check_long_token, skip_escaped_newlines, unterminated): New functions. (ACCEPT_CHAR, SAVE_STATE, RESTORE_STATE): New macros. (parse_identifier): Was parse_name, new implementation. (skip_line_comment, skip_block_comment, skip_whitespace, parse_number, parse_string, trigraph_ok, save_comment, adjust_column, _cpp_get_line): New implementations. (lex_token): New function. Lexes a token at a time, looking forwards. Contains most of the guts of the old lex_line. (lex_line): New implementation, using lex_token to obtain individual tokens. (cpp_scan_buffer): Use the token's line, not the list's line. * cpplib.c (_cpp_check_directive, _cpp_check_linemarker): New implementations. (do_assert): Don't bother setting the answer's list's line. (cpp_push_buffer): Initialise new pfile and read_ahead members of struct cpp_buffer. * cpplib.h (cppchar_t): New typedef. (struct cpp_buffer): read_ahead, pfile and col_adjust are new members. (struct lexer_state): New structure that determines the state and behaviour of the lexer. (IN_DIRECTIVE, KNOWN_DIRECTIVE): New macros. (struct cpp_reader): New member "state". Rename multiline_string_line and multiline_string_column. Delete col_adjust, in_lex_line members. (CPP_BUF_COLUMN): Update. * gcc.dg/cpp/cmdlne-C.c: Remove bogus warning test. From-SVN: r36509
2000-07-18[multiple changes]Zack Weinberg1-641/+173
2000-02-17 Zack Weinberg <zack@wolery.cumb.org> * cpphash.c: Don't include hashtab.h. Most macro-handling code moved to cppmacro.c. (hash_HASHNODE, eq_HASHNODE, _cpp_dump_macro_hash, dump_hash_helper): Delete. (expand_hash, higher_prime_number, _cpp_lookup_with_hash, cpp_forall_identifiers): New. Implement specialized version of Vlad's expandable hash table. (cpp_lookup): Use new functions. (_cpp_init_macros, _cpp_cleanup_macros): Adjust for new implementation. * cppmacro.c: New file. * cppinit.c (dump_macros_helper): New. (cpp_finish): Iterate over the identifier table directly. * cpplex.c (parse_name): Calculate the hash of the identifier while we scan it. Use _cpp_lookup_with_hash when we can. * cpphash.h: Update prototypes. (xcnewvec, HASHSTEP): New helper macros. * cpplib.h: Update prototypes. * Makefile.in (LIBCPP_OBJS): Add cppmacro.o. (cppmacro.o): New rule. (cpphash.o): Update deps. * cppmain.c: Do not set pfile->printer if no_output is on. 2000-02-15 Neil Booth <neilb@earthling.net> * cpplib.c: Change all directive-handler functions to return void, not int. * cpphash.h: Update typedefs. From-SVN: r35113
2000-07-15cpphash.c (save_expansion): Clear PREV_WHITE on tokens immediately following ↵Zack Weinberg1-0/+7
a paste operator. * cpphash.c (save_expansion): Clear PREV_WHITE on tokens immediately following a paste operator. * cppinit.c (sort_options): New function (only for HOST_EBCDIC). (cpp_reader_init): Call it, if HOST_EBCDIC. (cpp_handle_options): Do not sort option list here. (handle_option): Rename to cpp_handle_option and export. * cpplex.c (cpp_scan_buffer_nooutput, cpp_scan_buffer): Use _cpp_get_token directly. (cpp_scan_line): Return 0 at EOF, 1 otherwise. * cpplib.c (cpp_push_buffer): Don't set new->lineno to 1. * cpplib.h: Prototype cpp_handle_option. Update prototype of cpp_scan_line. From-SVN: r35052
2000-07-13cpphash.c (struct macro_info): Add new members.Neil Booth1-153/+146
* cpphash.c (struct macro_info): Add new members. (_cpp_free_definition): Delete the macro directly. (count_params): Return void, with first token of expansion in struct macro_info on success. (parse_define): Return int. Hoist syntax checking from save_macro_expansion. Leave call to save_expansion to _cpp_create_definition. (alloc_macro): Needs just 2 arguments. (free_macro): Delete. (save_expansion): Don't perform syntax check. (_cpp_create_definition): Call save_expansion. From-SVN: r35025
2000-07-13* cpphash.c (macro_info): Don't use the `signed' keyword.Kaveh R. Ghazi1-1/+1
From-SVN: r35023
2000-07-13cppexp.c, [...]: Eradicate all traces of code dependent on traditional, ↵Zack Weinberg1-24/+18
lang_chill, or lang_fortran. * cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c, cpplib.c, cpplib.h: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran. * cppfiles.c: #undef strcmp to suppress warning about macros used without arguments. (_cpp_execute_include): Use f, not fname, in "No include path" error. (_cpp_pop_file_buffer): New function. * cpplib.c: Don't include <sys/mman.h>. (cpp_push_buffer): Set line_base and lineno in new buffer. (cpp_pop_buffer): Use _cpp_pop_file_buffer. * cpplex.c: Move all prototypes and structure declarations to the top of the file. Properly parenthesise some macro arguments. (cpp_scan_line): New function. (special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth, don't need to walk up the stack counting. From-SVN: r35003
2000-07-12cppexp.c (LOGICAL): Delete macro.Zack Weinberg1-5/+7
* cppexp.c (LOGICAL): Delete macro. (_cpp_parse_expr): Do not use UNARY for unary +. Implement || and && directly. * cpphash.c (HASHSIZE): Increase to 4096. (struct hashdummy): Add hash field. (eq_HASHNODE): Compare unreduced hashes, then lengths, then the string values using memcmp. (cpp_lookup): Set dummy.hash. From-SVN: r34994
2000-07-12cpphash.h: (TOKEN_SPELL) Pulled from cpplex.c.Neil Booth1-89/+151
* cpphash.h: (TOKEN_SPELL) Pulled from cpplex.c. * cpplex.c (TOKEN_SPELL) Move to cpphash.h. * cpphash.c: (struct macro_info, alloc_macro, free_macro, struct toklist_dummy): New. (cpp_free_definition): Free macros with free_macro. (count_params): Don't save paramter spellings. Save macro information in a struct macro_info. (parse_define): Don't allocate a token list. (save_expansion): Allocate the macro's token list, and save parameter spellings if necessary. Use TOKEN_SPELL. (cpp_create_definition): Make list const. From-SVN: r34985
2000-07-11[multiple changes]Zack Weinberg1-1/+1
2000-07-11 Zack Weinberg <zack@wolery.cumb.org> * cpplex.c (parse_name): No longer inline (premature optimization). (do_pop_context): Fold into pop_context. (pop_context): Returns int. (lex_next): Hoist test for end of directive into pop_context. (push_macro_context): Returns int; takes just reader and token. Hoist test for excessive nesting to caller. (push_arg_context): Returns void; takes just reader and token. Do not call stringify_arg or get_raw_token. (get_raw_token): Convert tail recursion through push_arg_context to a loop at this level. Call stringify_arg here if appropriate. (maybe_paste_with_next): Convert tail recursion to a while loop. Hoist test of paste_level to caller. (stringify_arg): Push arg context at beginning. (cpp_get_token): Split out core into _cpp_get_token. Call process_directive here. Throw away CPP_PLACEMARKER tokens. (_cpp_get_token): Convert tail recursion through push_macro_context to a loop at this level. (_cpp_glue_header_name, is_macro_disabled, stringify_arg, _cpp_get_raw_token): Use _cpp_get_token. (_cpp_skip_rest_of_line): Drop the context stack directly; do not call pop_context. (_cpp_run_directive): Call lex_next directly. * cpphash.h: Prototype _cpp_get_token. * cppexp.c (lex): Use it. * cpphash.c (parse_define): Use it. * cpplib.c (get_define_node, do_undef, parse_include, read_line_number, do_line, do_ident, do_pragma, do_pragma_gcc, do_pragma_implementation, do_pragma_poison, do_pragma_dependency, parse_ifdef, validate_else): Use it. (cpp_push_buffer): Tweak error message; abort if anyone tries to push a buffer while macro expansions are stacked. 2000-07-11 Donn Terry <donnte@microsoft.com> * cpplex.c (free_macro_args, save_token): Cast arg of free and/or xrealloc to PTR. (_cpp_init_input_buffer): Clear all fields of the base context. From-SVN: r34972
2000-07-08cpplib.h (struct cpp_name): Now struct cpp_string.Zack Weinberg1-34/+24
* cpplib.h (struct cpp_name): Now struct cpp_string. (CPP_INT, CPP_FLOAT, CPP_NUMBER, CPP_COMMENT, CPP_HEADER_NAME): Change to type S. (struct cpp_token): Rename 'name' field to 'str'. Add 'node' field, a cpp_hashnode *. All references to val.name updated to use val.str or val.node as appropriate. (struct cpp_reader): Add spec_nodes field. (cpp_idcmp): Now cpp_ideq; takes a token * and a char *. * cpphash.h (struct spec_nodes): New. (enum spell_type): Reorder. Only SPELL_STRING tokens use val.str. All references to 'spelling > SPELL_NONE' updated to match. (CPP_IN_SYSTEM_HEADER): Check pfile->buffer and pfile->buffer->inc are not NULL before dereferencing them. * cpplex.c (parse_name): Take a pointer to the current token, plus current position and limit as args; return the new position; don't copy the text of a name into the string buffer, instead call cpp_lookup and store the node pointer. If extending a token, copy out the text of the old into a scratch buffer, append the new, look that up and store the new node pointer. Inline. (maybe_paste_with_next): If the result of paste is a NAME, then look up the pasted text and store its node pointer. (lex_line): Adjust for new parse_name interface. Check for L"str", L'str' using spec_nodes->n_L. (spell_token): SPELL_IDENT tokens have their spelling in val.node->name. Handle SPELL_STRING tokens that don't have string delimiters. (_cpp_expand_name_space, (can_paste): Check for L ## "str" using spec_nodes->n_L. (cpp_get_token, special_symbol): No need to call cpp_lookup. (cpp_idcmp): Now cpp_ideq; take a token * and a const char *; return 1=equal 0=not, not a tristate. * cpphash.c (var_args_str): Delete. (find_param): Compare node fields directly. (is__va_args__): Use CPP_PEDANTIC. Just compare token->val.node with spec_nodes->n__VA_ARGS__. (dump_funlike_macro): Don't use var_args_str. * cpplib.c (_cpp_check_directive): Just walk through spec_nodes->dirs comparing pointers. (get_define_node, do_pragma_poison, detect_if_not_defined, parse_ifdef): The identifier has already been looked up. (do_ifdef, do_ifndef): parse_ifdef won't return a poisoned node. (do_if): Only call detect_if_not_defined at beginning of file. (_cpp_parse_assertion): Only copy string pointers for SPELL_STRING tokens. (pragma_dispatch): Take a node pointer and examine its name field. (_cpp_init_stacks): Also initialize the spec_nodes structure. * cppinit.c (cpp_reader_init): Call _cpp_init_stacks after _cpp_init_macros. (cpp_cleanup): Free pfile->spec_nodes. Call _cpp_cleanup_* in reverse order from the corresponding _cpp_init_* routines. * cppexp.c (parse_number, parse_charconst, parse_defined, lex): Check val.node->type instead of calling cpp_defined. Use spec_nodes entries where appropriate. * fix-header.c, scan-decls.c: Update for interface changes. From-SVN: r34926
2000-07-08cpphash.c (is__va_args__): New function.Neil Booth1-29/+56
* cpphash.c (is__va_args__): New function. (count_params): Fix line reported in error messages. Use is__va_args__. Don't return ')' on error. Flag GNU style rest args macro definitions. (parse_define): Check macro name is not __VA_ARGS__. (save_expansion): Check identifier in non-varargs-macro is not __VA_ARGS__. Don't flag GNU_VARARGS. * cpplex.c (parse_args): Accept no argument iff GNU_REST_ARGS. (maybe_paste_with_next): Use per-macro GNU_REST_ARGS rather than per-token GNU_VARARGS. * cpplib.h (GNU_VARARGS): Remove. (GNU_REST_ARGS): New. * gcc.dg/cpp/macsyntx.c: New tests. From-SVN: r34919
2000-07-05cpplex.c: Don't include sys/mman.h.Zack Weinberg1-44/+31
toplevel: * cpplex.c: Don't include sys/mman.h. (cpp_push_buffer, cpp_pop_buffer): Moved to cpplib.c. * cpplib.c: Include sys/mman.h and obstack.h. (cpp_push_buffer): Moved from cpplex.c; allocate buffers on an obstack. (cpp_pop_buffer): Moved from cpplex.c; free buffers from an obstack. (_cpp_unwind_if_stack): Now static, unwind_if_stack. Don't bother freeing if stack entries (they will be freed with their buffer). (do_endif): Free if stack entries from the buffer obstack. (push_conditional): Allocate if stack entries from the buffer obstack. (find_answer): Rename to _cpp_find_answer. (do_assert, do_unassert): Update. * cpphash.h: Update prototypes. (xobnew): New convenience macro. * cpplib.h (struct cpp_reader): Add hash_ob and buffer_ob fields. Update comments. (struct cpp_hashnode): Remove disabled field. * cppinit.c: Don't include hashtab.h or splay-tree.h. (report_missing_guard): Moved to cppfiles.c. (cpp_reader_init): Call cpp_init_stacks, cpp_init_macros, cpp_init_includes. (cpp_cleanup): Call cpp_cleanup_stacks, cpp_cleanup_macros, cpp_cleanup_includes. Don't destroy hashtab or all_include_files here. (cpp_finish): Use _cpp_report_missing_guards. * cppfiles.c (report_missing_guard): Moved from cppinit.c. (_cpp_init_include_table): Rename _cpp_init_includes. (_cpp_cleanup_includes, _cpp_report_missing_guards): New. * cppexp.c (parse_assertion): Update for new name of find_answer. * Makefile.in (cpplib.o, cpphash.o, cppinit.o): Update deps. * cpplib.c (do_ident): s/VSPACE/EOF/ testsuite: * gcc.dg/cpp/ident.c: New test. From-SVN: r34870
2000-07-04top level:Zack Weinberg1-1638/+360
2000-07-03 Zack Weinberg <zack@wolery.cumb.org> * fix-header.c (struct partial_proto): Remove unnecessary fields. (recognized_extern, recognized_function, read_scan_file): Update for new scheme. (check_protection): It's still a multiple include guard even if it doesn't always trigger. * scan-decls.c (skip_to_closing_brace, scan_decls): Update for new scheme. * scan.h: Declare struct cpp_token. Update prototypes. 2000-07-03 Neil Booth <neilb@earthling.net> Zack Weinberg <zack@wolery.cumb.org> Complete overhaul of the lexer and macro expander. * cpphash.c (object_defn, funct_defn, push_macro_expansion, arg, arglist, argdata, reflist, collect_objlike_expansion, collect_funlike_expansion, collect_params, warn_trad_stringify, trad_stringify, duplicate_arg_p, add_pat, unsafe_chars, macarg, compare_defs, special_symbol, scan_arguments, stringify, funlike_macroexpand, _cpp_quote_string, monthnames): Delete. (cpp_lookup, _cpp_free_definition, dump_funlike_macro, _cpp_create_definition, _cpp_dump_definition, dump_hash_helper): Adjust. (find_param, count_params, parse_define, var_args_str, check_macro_redefinition, save_expansion): New. * cpplex.c (skip_block_comment, skip_line_comment, parse_name, parse_string, output_line_command, trigraph_replace, lex_line, cpp_push_buffer, cpp_pop_buffer, cpp_output_tokens, cpp_scan_buffer_nooutput, cpp_scan_buffer, cpp_free_toklist, cpp_idcmp, _cpp_get_directive_token, _cpp_init_input_buffer, _cpp_skip_rest_of_line): Modify. (maybe_macroexpand, skip_comment, copy_comment, skip_string, find_position, null_warning, bump_column, expand_name_space, pedantic_whitespace, _cpp_output_list, _cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_scan_until, _cpp_skip_hspace, _cpp_parse_name, _cpp_lex_token, cpp_get_non_space_token, _cpp_prescan): Delete. (dump_param_spelling, process_directive, lex_next, is_macro_disabled, stringify_arg, expand_context_stack, output_token, make_string_token, alloc_number_token, special_symbol, duplicate_token, maybe_paste_with_next, can_paste, prevent_macro_expansion, restore_macro_expansion, get_temp_token, release_temp_tokens, quote_string, token_names, token_spellings, _cpp_expand_name_space, _cpp_glue_header_name, _cpp_reserve_name_space, digraph_spellings, trigraph_ok, skip_whitespace, save_comment, placemarker_token, eof_token, cpp_context, macro_args, get_raw_token, parse_arg, parse_args, save_token, push_arg_context, push_macro_context, pop_context, do_pop_context, free_macro_args, _cpp_get_line, _cpp_run_directive): New. * cpplib.c (validate_else, parse_include, push_conditional, pass_thru_directive, read_line_number, parse_ifdef, detect_if_not_defined, _cpp_check_directive, do_define, do_undef, do_include, do_import, do_include_next, do_error, do_warning, do_ident, do_pragma, pragma_dispatch, gcc_pragmas, top_pragmas, do_pragma_gcc, do_pragma_implementation, do_pragma_poison, do_pragma_system_header, do_pragma_dependency, do_sccs, do_ifdef, do_ifndef, do_else, dl_elif, do_endif, _cpp_unwind_if_stack, do_assert, do_unassert, cpp_define, cpp_undef, cpp_assert, cpp_unassert, cpp_defined): Update for new scheme. (strtoul_for_line, get_define_node, dump_macro_name, _cpp_check_linemarker, _cpp_parse_assertion): New. (_cpp_handle_directive, do_pragma_default): Delete. * cpphash.h (struct predicate): Now struct answer. (enum spell_type, struct token_spelling, struct directive, directive_handler): New. Update prototypes. Remove unused macros. * cpplib.h: Update prototypes. Remove unused macros, structure definitions, and fields. * cpperror.c (print_containing_files, v_message): Adjust. * cppexp.c (parse_assertion, lex, parse_escape, _cpp_parse_expr): Adjust. * cppfiles.c (open_include_file, _cpp_execute_include, _cpp_compare_file_date, cpp_read_file, read_include_file): Adjust. * cppinit.c (dump_special_to_buffer): Delete. (append_include_chain, merge_include_chains, cpp_reader_init, cpp_cleanup, initialize_builtins, builtin_array, cpp_start_read, cpp_finish, handle_option, print_help): Adjust. * cppmain.c (main): Adjust. testsuite: 2000-07-03 Zack Weinberg <zack@wolery.cumb.org> * testsuite/gcc.dg/cpp/19951025-1.c: Adjust regexps. * testsuite/gcc.dg/cpp/19990703-1.c: Likewise. * testsuite/gcc.dg/cpp/20000625-1.c: Likewise. * testsuite/gcc.dg/cpp/20000625-2.c: Likewise. * testsuite/gcc.dg/cpp/macro1.c, testsuite/gcc.dg/cpp/paste1.c, testsuite/gcc.dg/cpp/paste2.c, testsuite/gcc.dg/cpp/paste3.c, testsuite/gcc.dg/cpp/paste4.c, testsuite/gcc.dg/cpp/strify1.c, testsuite/gcc.dg/cpp/strify2.c: New tests. From-SVN: r34859
2000-06-21cppfiles.c: Include splay-tree.h, not hashtab.h.Zack Weinberg1-1/+1
* cppfiles.c: Include splay-tree.h, not hashtab.h. (redundant_include_p, make_IHASH, hash_IHASH, eq_IHASH): Delete. (destroy_include_file_node): New. (_cpp_init_include_hash): Rename _cpp_init_include_table. Create a splay tree, not a hash table. (open_include_file): Look up the path in the include table, do the multiple include optimization here, etc. (cpp_included): Walk the path. (find_include_file): Just walk the path calling open_include_file, or call it directly for an absolute path. (_cpp_fake_ihash): Rename _cpp_fake_include and update for new scheme. (read_include_file): Update for new scheme. Don't close the file unless reading fails. (_cpp_execute_include, cpp_read_file): Tweak for new scheme. * cpphash.h (struct ihash, NEVER_REINCLUDE): Delete. (struct include_file): New. (NEVER_REREAD, DO_NOT_REREAD, CPP_IN_SYSTEM_HEADER): New macros. (CPP_PEDANTIC, CPP_WTRADITIONAL): Update. Update prototypes. * cppinit.c: Include splay-tree.h. (cpp_reader_init, cpp_cleanup): Update. * cpplib.h (struct cpp_buffer): Change ihash field to 'struct include_file *inc'. Remove system_header_p. (struct cpp_reader): Change all_include_files to a struct splay_tree_s *. * cpplex.c: Update all references to cpp_buffer->ihash and/or cpp_buffer->system_header_p. (cpp_pop_buffer): Close file here, only if DO_NOT_REREAD. From-SVN: r34636
2000-05-28cppfiles.c: Read files in, using mmap if possible, then prescan them separately.Zack Weinberg1-29/+29
* cppfiles.c: Read files in, using mmap if possible, then prescan them separately. (read_file, read_with_read): New functions. * cpplex.c: Don't define UCHAR_MAX. (_cpp_read_and_prescan): Rename to _cpp_prescan. Don't read the file here. * cppinit.c (handle_option): Automatically define __cplusplus, __OBJC__, __ASEEMBLER__, _LANGUAGE_FORTRAN here when we see the respective -lang switch. * cpphash.h (enum node_type, struct hashnode, _cpp_lookup prototype): Move to... * cpplib.h: ... here. Rename struct hashnode to struct cpp_hashnode and give it a typedef. Rename _cpp_lookup to cpp_lookup. Add 'fe_value' slot, a union tree_node *. From-SVN: r34228
2000-05-19cpphash.c (funlike_macroexpand): Make sure not to walk p1 past l1 when ↵Zack Weinberg1-3/+3
deleting whitespace and markers. * cpphash.c (funlike_macroexpand): Make sure not to walk p1 past l1 when deleting whitespace and markers. From-SVN: r34027
2000-05-18cppexp.c (parse_assertion): New.Zack Weinberg1-21/+6
* cppexp.c (parse_assertion): New. (lex): Call it for CPP_HASH. Remove CPP_ASSERTION case. (_cpp_parse_expr): Remove case '#'. Don't set parsing_if_directive. * cpphash.c (collect_objlike_expansion, collect_funlike_expansion, collect_params, _cpp_create_definition): The list no longer has a trailing VSPACE token. * cpphash.h (enum node_type): Add T_ASSERTION. (struct hashnode): Remove aschain, add pred. (struct predicate): New. Update prototypes. * cpplex.c (expand_token_space): Handle both offset and nonoffset lists. (init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete. (_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist, _cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens, _cpp_equiv_toklists): New. (_cpp_scan_line): Rename to _cpp_scan_until; add ability to stop at any single-character token, not just newline. (_cpp_lex_token): Remove special cases for #define and #if. (cpp_get_token): Expect # as a separate token type. Remove DIRECTIVE case. (_cpp_get_directive_token): Remove DIRECTIVE case. (_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update. * cpplib.c (_cpp_check_directive): Set dirno and SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags. (_cpp_handle_directive): Run # <number> through the same logic as normal directives. (do_define): Don't set parsing_define_directive. Use _cpp_scan_until. The list does not have a VSPACE at the end. (do_if): Save, clear, and restore only_seen_white around _cpp_parse_expr. (skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/ (do_assert, do_unassert): Rewrite. * cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION. (LIST_OFFSET): New flag. (struct cpp_toklist): Replace dir_handler and dir_flags with dirno and flags. (struct cpp_reader): Remove parsing_if_directive and parsing_define_directive. From-SVN: r33984
2000-05-14cpphash.c (trad_stringify, [...]): Make some pointers pointers to const.Neil Booth1-8/+11
* cpphash.c (trad_stringify, warn_trad_stringify, collect_params): Make some pointers pointers to const. * cpplex.c (auto_expand_name_space) Guaranteed to always expand by at least one character. (SPELL_CHAR, SPELL_NONE): Temporarily reverse order. (struct token_spelling): Use const U_CHAR * rather than PTR. (expand_name_space): Fix up token pointers if name space is moved when expanding. (INIT_NAME, cpp_scan_line, parse_name, parse_number, parse_string2, save_comment, spell_token, cpp_output_list): Update so the routines handle tokens with a direct pointer to their text, rather than an offset into the token's list's namebuf. (_cpp_lex_line): Rearrange for clarity. * cpplib.c (_cpp_check_directive): Similarly. (do_define): Make SYM a pointer to const. * cpplib.h (struct cpp_name): Replace offset with direct pointer. (CPP_INT, CPP_FLOAT): Spelling type should be SPELL_IDENT. (TOK_OFFSET): Delete. (TOK_NAME): Update. From-SVN: r33901
2000-05-11cpphash.c (collect_funlike_expansion): Make "# is not followed by a macro ↵Zack Weinberg1-1/+16
argument name" a pedwarn, not an error. * cpphash.c (collect_funlike_expansion): Make "# is not followed by a macro argument name" a pedwarn, not an error. Preserve the # in the output. Suppress the warning if lang_asm. * gcc.dg/dg.exp: Scan .S files as well as .c files. * gcc.dg/20000510-1.S: New. From-SVN: r33841
2000-05-10cpphash.h (struct hashnode): Use struct hack for name member.Zack Weinberg1-11/+21
* cpphash.h (struct hashnode): Use struct hack for name member. * cpphash.c (struct hashdummy): New. (eq_HASHNODE): Second argument is a hashdummy, not a HASHNODE. (make_HASHNODE): No need to set ->name pointer. Correct setting of p. (cpp_lookup): Make 'dummy' a struct hashdummy. Tidy up a bit. From-SVN: r33828
2000-05-04cpphash.h (U): New define, to correct type of string constants.Zack Weinberg1-28/+33
gcc: * cpphash.h (U): New define, to correct type of string constants. (ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr): New wrapper routines, to do casts when passing unsigned strings to libc. * cppexp.c, cppfiles.c, cpphash.c, cppinit.c, cpplib.c: Use them. * cppfiles.c (_cpp_execute_include): Make filename an U_CHAR *. * cpphash.c (_cpp_quote_string): Make string an U_CHAR *. * cppinit.c (dump_special_to_buffer): Make macro name an U_CHAR *. * cpplex.c (parse_ifdef, parse_include, validate_else): Make second argument an U_CHAR *. * cppinit.c (builtin_array): Make name and value U_CHAR *, add length field, clean up initializer. (ISTABLE): Add __extension__ to designated- initializers version. * cpplex.c (CHARTAB): Likewise. * mbchar.c: Add dummy external declaration to the !MULTIBYTE_CHARS case so the file won't be empty. include: * symcat.h: Remove #endif label. From-SVN: r33657
2000-05-03cpplib.h: Add accessor macros for token lists.Zack Weinberg1-38/+34
* cpplib.h: Add accessor macros for token lists. * cpplib.c, cpphash.c, cpplex.c: Use them. From-SVN: r33630
2000-05-02cpphash.c (collect_params): Fix off-by-one error.Zack Weinberg1-2/+3
* cpphash.c (collect_params): Fix off-by-one error. (dump_hash_helper): Dump all four macro nodetypes. From-SVN: r33613
2000-05-02cpphash.c (trad_stringify): Adjust p after stringification as well.Jakub Jelinek1-0/+1
* cpphash.c (trad_stringify): Adjust p after stringification as well. * gcc.dg/cpp-tradstringify.c: New test. From-SVN: r33612
2000-05-02cpplib.h (CPP_POP, [...]): Delete.Zack Weinberg1-28/+6
* cpplib.h (CPP_POP, parse_cleanup_t): Delete. (cpp_buffer): Remove cleanup, seen_eof, manual_pop members. * cppfiles.c (file_cleanup): Delete. * cpphash.c (macro_cleanup): Delete. (collect_objlike_expansion, collect_funlike_expansion, macarg, scan_arguments): Remove CPP_POP case. * cpplex.c (null_cleanup): Delete. (cpp_pop_buffer): Do the work that was done in the cleanups here. Call _cpp_unwind_if_stack from here. (_cpp_expand_to_buffer, cpp_scan_buffer_nooutput, cpp_scan_buffer): Run until we see CPP_EOF and the top of stack is the buffer _below_ the one we stacked. (cpp_get_token): Always pop an exhausted buffer. Return CPP_EOF unless it's a macro buffer. Don't call _cpp_handle_eof. * cpplib.c (skip_if_group): Don't call cpp_get_token to increment the line number. (_cpp_handle_eof): Rename to _cpp_unwind_if_stack. * fix-header.c (read_scan_file) [parsing getchar()]: Run until we see CPP_EOF and the top of stack is the buffer _below_ the one we stacked. * scan-decls.c: Likewise. From-SVN: r33611
2000-05-01cpphash.c (_cpp_make_hashnode): Rename make_HASHNODE, now static.Zack Weinberg1-29/+17
* cpphash.c (_cpp_make_hashnode): Rename make_HASHNODE, now static. Allocate the hashnode and its string in the same block of memory. (del_HASHNODE): Don't free h->name. (_cpp_lookup): If there is no entry for this string, create one, of type T_VOID. (_cpp_lookup_slot): Delete. * cpphash.h: Update prototypes. * cpplex.c (maybe_macroexpand): Check for hp->type == T_VOID, not hp == NULL. * cpplib.c (do_define, do_undef, do_pragma_poison, do_assert, do_unassert, cpp_defined): Use _cpp_lookup. Don't create a node here, just fill in the value field properly. "Delete" entries by setting the value field to T_VOID. Check for hp->type == T_VOID, not hp == NULL. * Makefile.in (cpplib.o): Don't depend on $(HASHTAB_H). * cpperror.c, cppexp.c, cpplex.c, cpplib.c: Don't include hashtab.h. From-SVN: r33581
2000-04-30cppfiles.c (redundant_include_p): Provide length of token to cpp_defined.Zack Weinberg1-27/+5
* cppfiles.c (redundant_include_p): Provide length of token to cpp_defined. * cpphash.c (_cpp_make_hashnode, _cpp_lookup_slot): Hash values are unsigned int. (_cpp_lookup, _cpp_lookup_slot): Do not calculate the length. (_cpp_lookup_slot): Do not calculate the hash, either. * cpphash.h: Update prototypes. * cpplib.c (do_define, do_undef, do_pragma_poison, do_assert): Hashes are unsigned int. Calculate hash here, pass by value to _cpp_lookup_slot. From-SVN: r33551
2000-04-30cpphash.h (enum node_type): Take out T_MCONST.Zack Weinberg1-122/+168
* cpphash.h (enum node_type: Take out T_MCONST. (union hashval): Move into struct hashnode. (struct hashnode): Pack tighter. Remove file, line, col members. * cpphash.c: Constify most of the macro-definition structures. (struct definition): Replace by struct object_defn and struct funct_defn. Put file, line, column information here. All users updated to match. (_cpp_create_definition, _cpp_macroexpand): Remove special case for #define WORD OTHERWORD. * cpplib.c (do_undef): Remove T_MCONST case. From-SVN: r33538
2000-04-29cpphash.h: Move struct reflist, struct definition, and the DEFINITION ↵Zack Weinberg1-21/+69
typedef to cpphash.c. * cpphash.h: Move struct reflist, struct definition, and the DEFINITION typedef to cpphash.c. Use 'struct definition *' in union hashval. _cpp_free_definition takes a HASHNODE pointer. * cpphash.c (_cpp_free_definition): Free data pointed to by MCONST, XCONST, MACRO, and FMACRO nodes properly. (_cpp_create_definition, del_HASHNODE): Just call _cpp_free_definition to clear out a hashnode. * cpplib.c (do_pragma_poison): Likewise. From-SVN: r33536
2000-04-25[multiple changes]Zack Weinberg1-6/+7
2000-04-25 Zack Weinberg <zack@wolery.cumb.org> * cpplib.h (struct cpp_buffer): Add 'mapped' flag; fix commentary. 2000-04-25 Neil Booth <NeilB@earthling.net> Restore previous patch, plus the following fixes: * cpphash.c (_cpp_create_definition): Test PREV_WHITESPACE in flags, not CPP_OPEN_PAREN. * cpplex.c (expand_token_space, init_token_list, cpp_free_token_list): Put the dummy token at list->tokens[-1]. (_cpp_lex_line, _cpp_lex_file): token list is 0-based. From-SVN: r33419
2000-04-25* Revert previous patch until build failure cause determined.Neil Booth1-6/+5
From-SVN: r33411
2000-04-24cpphash.c: replace HSPACE_BEFORE with PREV_WHITESPACE.Neil Booth1-5/+6
* cpphash.c: replace HSPACE_BEFORE with PREV_WHITESPACE. * cpphash.h (_cpp_check_directive): new. * cpplex.c (handle_newline, cpp_free_token_list, init_trigraph_map, trigraph_ok, trigraph_replace, backslash_start, skip_block_comment, skip_line_comment, skip_whitespace, parse_name, parse_number, parse_string, copy_comment, _cpp_lex_line, spell_char, spell_string, spell_comment, spell_name, spell_other, _cpp_lex_file, _cpp_output_list): new. (expand_name_space): take length argument. (init_token_list): add comment list initialisation. (cpp_scan_line): use auto_expand_name_space. PREV_WHITESPACE instead of HSPACE_BEFORE. * cpplib.c (_cpp_check_directive): new * cpplib.h (cpp_name, PREV_WHITESPACE, PREV_COMMENT, DIGRAPH, UNSIGNED_INT, TOK_NAME): new. (HSPACE_BEFORE): delete. (TTYPE_TABLE): rearrange. (struct cpp_toklist): update. From-SVN: r33390
2000-04-23cpphash.c (collect_objlike_expansion): Add sanity check.Zack Weinberg1-23/+19
* cpphash.c (collect_objlike_expansion): Add sanity check. (special_symbol): Remove case T_CONST, T_XCONST, T_MCONST. If the buffer is the empty string, return. Mark __DATE__ and __TIME__ as XCONST nodes, not MCONST. (_cpp_macroexpand): Avoid pushing an empty buffer. (funlike_macroexpand): Don't pop token_buffer here. From-SVN: r33360
2000-04-23cpphash.h (struct definition): Move file, line, col members...Zack Weinberg1-507/+719
* cpphash.h (struct definition): Move file, line, col members... (struct hashnode): ... here. Also add 'disabled' flag. (enum node_type): Add T_VOID, T_XCONST, T_FMACRO, and T_IDENTITY. Remove T_DISABLED. Update prototypes. * cpphash.c (_cpp_dump_definition): Split out dump_DEFINITION. (collect_expansion): Split into collect_objlike_expansion and collect_funlike_expansion. (_cpp_macroexpand): Split out scan_arguments, stringify, and funlike_macroexpand. (_cpp_compare_defs): Rename compare_defs, make static. (_cpp_make_hashnode): Initialize hp->disabled. (macro_cleanup): Adjust for new token types. Clear m->disabled. (_cpp_create_definition): Move code here to determine what sort of macro it is, and code to check for redefinitions, from do_define. Implement a few simple cases without creating a full DEFINITION. (_cpp_macroexpand, special_symbol, _cpp_dump_definition): Handle the simple cases. (push_macro_expansion): Set buf->has_escapes and hp->disabled here. * cppinit.c (builtin_array): Change MCONST to XCONST everywhere. * cpplex.c (maybe_macroexpand): Handle IDENTITY macros here; fix check for disabled and function-like macros. * cpplib.c (do_define): Move most logic to _cpp_create_definition. (do_undef): Handle new special token types. From-SVN: r33355
2000-04-22cpphash.c (trad_stringify, add_pat): New functions.Zack Weinberg1-37/+147
* cpphash.c (trad_stringify, add_pat): New functions. (collect_expansion): Restore support for -traditional syntax. Use trad_stringify and add_pat. (_cpp_macroexpand): Restore support for -traditional semantics. * cpplex.c (_cpp_scan_line): Don't change space_before if we get a COMMENT token. (_cpp_lex_token): Provide COMMENT tokens to caller if traditional and parsing_define_directive. (skip_comment): Warn about // comments if -Wtraditional. * cpplib.c (do_define): Fix typo. Create EMPTY nodes with proper node type. (do_undef): Don't warn about undefining EMPTY nodes. From-SVN: r33350
2000-04-21cpphash.c (struct arg, [...]): Const-ify strings.Zack Weinberg1-405/+266
* cpphash.c (struct arg, struct arglist): Const-ify strings. (warn_trad_stringify, duplicate_arg_p): New helper functions. (collect_expansion): Rewrite to scan over a token list. Remove -traditional support. (collect_formal_parameters): Rename to collect_params; rewrite to scan over a token list. (_cpp_create_definition): Adjust to scan a token list. (_cpp_macroexpand): Remove -traditional support. (_cpp_compare_defs): Whitespace is now canonicalized. (comp_def_part): Delete function. * cpphash.h: Update prototypes. * cpplex.c (init_token_list): Don't set lineno if there is no buffer. (pedantic_whitespace): New function. (_cpp_scan_line): Mark tokens that had hspace before. Don't consume a newline. Use pedantic_whitespace. (_cpp_lex_token): Remove support for -traditional macros. (_cpp_get_define_token): Delete. (_cpp_get_directive_token): Do the real work here. Use pedantic_whitespace. (_cpp_init_input_buffer): Initialize pfile->directbuf. * cpplib.c (get_macro_name): Delete. (do_define): Read the entire line into pfile->directbuf, then feed the token list to _cpp_create_definition. * cpplib.h (HSPACE_BEFORE): new define. (struct cpp_reader): Add a toklist member, "directbuf". From-SVN: r33309
2000-04-20cpplib.h (enum cpp_ttype): Add token types for all punctuators.Zack Weinberg1-11/+11
* cpplib.h (enum cpp_ttype): Add token types for all punctuators. Distinguish pp-numbers from valid C numbers. Give some tokens better names. Initialize from macro. (struct cpp_name, cpp_token, cpp_toklist): New data structures. Update prototypes. * cpplex.c (bump_column, expand_name_space, expand_token_space, init_token_list, cpp_output_list, _cpp_scan_line): New functions. (output_line_command): Add third argument, new line number. * cpphash.h: Update prototypes. * cppexp.c, cpphash.c, cpplib.c, scan-decls.c: Update for new token names. From-SVN: r33289
2000-04-19cpphash.c (special_symbol): Represent an empty macro with "\r \r " not just ↵Zack Weinberg1-14/+17
"\r ". * cpphash.c (special_symbol): Represent an empty macro with "\r \r " not just "\r ". (_cpp_macroexpand): Correct condition for the foo ( ) special case. (unsafe_chars): Handle EOF as second argument. (push_macro_expansion): Simplify test for removing escape at end. Do not trim both escapes if there is no text in between. * gcc.dg/20000419-1.c: New test. From-SVN: r33267
2000-04-18conflict.c (conflict_graph_add): Pass enum type to htab_find_slot.Richard Kenner1-4/+8
* gcc/conflict.c (conflict_graph_add): Pass enum type to htab_find_slot. * gcc/cpperror.c (hashtab.h): Now include. * gcc/cppexp.c (hashtab.h): Likewise. * gcc/cpplex.c (hashtab.h): Likewise. * gcc/cppfiles.c (hashtab.h): Likewise. (find_include_file, _cpp_calc_hash, cpp_read_file): Pass enum type to htab_find_slot_with_hash. * gcc/cpphash.c (hashtab.h): Now include. (_cpp_lookup_slot): INSERT is now enum insert_option. * gcc/cpphash.h (_cpp_lookup_slot): Likewise. * gcc/cppinit.c (hashtab.h): Include earlier. (initialize_builtins): Pass enum to htab_find_slot. * gcc/cpplib.c (hashtab.h): Now include. (do_define, do_undef): Pass enum type to _cpp_lookup_slot. (do_pragma_poison, do_assert): Likewise. * gcc/emit-rtl.c (gen_rtx_CONST_INT): Pass enum to htab_find_slot_with_hash. * gcc/simplify-rtx.c (cselib_lookup_mem, cselib_lookup): Likewise. * gcc/tree.c (type_hash_add): Likewise. (build1): Minor cleanup. * include/hashtab.h (enum insert_option): New type. (htab_find_slot, htab_find_slot_with_hash): Use it. * libiberty/hashtab.c: Various minor cleanups. (htab_find_slot_with_hash): INSERT is now enum insert_option. (htab_find_slot): Likewise. From-SVN: r33236
2000-04-18cppexp.c (lex): Don't assume tokens are NUL terminated.Zack Weinberg1-21/+29
* cppexp.c (lex): Don't assume tokens are NUL terminated. * cpplib.c (do_include, do_import, do_include_next, read_line_number, detect_if_not_defined): Likewise. * cpphash.c (collect_expansion): Likewise. (special_symbol, _cpp_macroexpand): Check return from cpp_file_buffer. * cpphash.h (CPP_NUL_TERMINATE, CPP_NUL_TERMINATE_Q): Delete macros. Delete all uses. * gcc.dg/cpp-mi.c: Add two more test cases. * gcc.dg/cpp-mind.h, gcc.dg/cpp-mindp.h: New files. From-SVN: r33223
2000-04-14cpplex.c (cpp_output_tokens, [...]): New public interfaces.Zack Weinberg1-14/+6
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public interfaces. (safe_fwrite, output_line_command): New static functions. (cpp_expand_to_buffer): Now private to cpplib. (cpp_scan_buffer): Take a printer. * cpphash.h: Update prototypes. * cpplib.h: Update prototypes. (cpp_printer): New. (cpp_buffer): Remove last_nominal_fname. (cpp_reader): Remove lineno. * cppmain.c: Use a cpp_printer. * fix-header.c: No need to inhibit line commands. Call cpp_start_read with no printer. * cpperror.c (cpp_notice_from_errno): Provide default name. * cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions. (find_include_file, cpp_read_file): Use make_IHASH. (file_cleanup): Set control_macro and clear input_stack_listing_current here. (_cpp_execute_include): Don't output entering-file marker. * cpphash.c (special_symbol): Look for the line number in the buffer, not the reader. (_cpp_macroexpand): No need to disable line commands. (_cpp_dump_definition): No need to generate line commands. (dump_hash_helper): Remove excess newline from output. * cppinit.c (dump_special_to_buffer): No need to generate line commands. (cpp_printer_init): New. (cpp_start_read): Take a printer, and start it up if it's not NULL. No need to generate line commands. (cpp_finish): Expect no buffers stacked at all. Take a printer argument, and flush the output buffer if it's not NULL. * cpplex.c (_cpp_lex_token): Return EOF if there's no buffer. Don't put two hashes at the beginning of an assertion. (cpp_get_token): Don't increment pfile->lineno or emit line commands here. Return EOF if there's no buffer when we get EOF. * cpplib.c (do_define, skip_if_group): No need to disable line commands. (_cpp_output_line_command): Delete function. (do_line): Don't emit line commands here, but set things up so they will be emitted if necessary. Use _cpp_fake_ihash to make unique nominal_fnames if necessary. (do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line with 0 for column, not -1. (_cpp_handle_eof): Don't set the control macro here. Don't clear input_stack_listing_current here. Don't emit line commands. From-SVN: r33159
2000-04-11cppexp.c, [...]: Replace cpp_token with cpp_ttype everywhere.Zack Weinberg1-19/+19
* cppexp.c, cpphash.c, cpphash.h, cpplex.c, cpplib.c, cpplib.h, cppmain.c, fix-header.c, scan-decls.c: Replace cpp_token with cpp_ttype everywhere. * cpperror.c, cpphash.c, cpplex.c, cpplib.c, scan-decls.c: Replace cpp_buf_line_and_col with CPP_BUF_LINE and/or CPP_BUF_COL. Line and column numbers are unsigned int, not long. * cpplex.c (cpp_buf_line_and_col): Delete. * cpplib.h (struct cpp_buffer, struct cpp_reader): Change 'long lineno' to 'unsigned int lineno'. (CPP_BUF_LINE, CPP_BUF_COL): New macros. From-SVN: r33076
2000-04-10cpphash.c (timestamp): Delete.Zack Weinberg1-61/+47
* cpphash.c (timestamp): Delete. (del_HASHNODE): If type is T_MCONST, free value.cpval. (special_symbol): Remove unnecessary braces. Remove T_VERSION. Treat T_STDC like T_CONST unless STDC_0_IN_SYSTEM_HEADERS. Render both __DATE__ and __TIME__ when one is encountered, then convert them into T_MCONST nodes. * cppinit.c (builtin_array): version_string is T_MCONST. __STDC__ has a "1" in its cpval. Don't have a terminator entry. Clean up which entries are dumped. (initialize_builtins): Only __STDC__ gets the special -traditional treatment. Count the length of builtin_array. Render version_string here. * cpphash.h: Remove T_VERSION. Add T_MCONST. * cpplib.h (struct cpp_reader): Remove timebuf. From-SVN: r33047
2000-04-06cpphash.c (CPP_IS_MACRO_BUFFER, [...]): Delete.Zack Weinberg1-69/+44
* cpphash.c (CPP_IS_MACRO_BUFFER, FORWARD, PEEKC): Delete. (macro_cleanup): No need to cast pbuf->macro. (collect_expansion): Use _cpp_get_define_token. Goto done if it returns VSPACE. Remove check for trailing space after CPP_COMMENT. (_cpp_create_definition): Don't diddle flags here. Return directly on error. (unsafe_chars): Handle c1 being EOF. (push_macro_expansion): Use unsafe_chars for both accidental-paste checks. Don't push the buffer till after we're done with them. * cpplex.c (PEEKBUF, GETBUF, FORWARDBUF): New. (PEEKN, FORWARD, GETC, PEEKC): Use them. (cpp_push_buffer): Don't set new->alimit. Set new->mark appropriately. (_cpp_parse_assertion): Don't NUL terminate. (_cpp_lex_token): Fix -traditional macro handling. Don't skip hspace before calling _cpp_parse_assertion. Remove all sets of only_seen_white. Treat '\f' as hspace. Don't do anything special with '\n' here. (maybe_macroexpand): Handle T_EMPTY hash entries without pushing a buffer at all. (cpp_get_token): Handle clearing only_seen_white here. Handle incrementing the line number here. Clear potential_control_macro as well as only_seen_white, if appropriate. (cpp_get_non_space_token): Don't eat CPP_POP tokens. (_cpp_get_define_token): New function, basically like _cpp_get_directive_token was but doesn't eat horizontal space. Don't do anything with only_seen_white here. (_cpp_get_directive_token): Just call _cpp_get_define_token repeatedly till it returns non-hspace. * cpplib.c (PEEKN, FORWARD, GETC, PEEKC): Delete. (conditional_skip, skip_if_group): Return int. (DIRECTIVE_TABLE): Change origin of all conditional directives to "COND". (TRAD_DIRECT_P): New macro. (_cpp_handle_directive): Use _cpp_get_directive_token. Issue an error for a bogus directive, unless -lang-asm. Use TRAD_DIRECT_P. Loop calling handler functions till one returns zero. (get_macro_name): Don't diddle flags here. (do_define): Diddle flags here. Use _cpp_get_directive_token. Create T_EMPTY nodes for #define macro /* nothing */. (do_undef): Don't copy the name. Use _cpp_get_directive_token. Use hp->name when calling pass_thru_directive. (do_if, do_else, do_elif, do_ifdef, do_ifndef, conditional_skip): Return the result of conditional_skip and/or skip_if_group. Don't call _cpp_output_line_command. (consider_directive_while_skipping): Use _cpp_get_directive_token. Issue -Wtraditional warnings as appropriate. Don't complain about unrecognized directives. If we are to stop skipping, return the number of the directive that ended the skip. (skip_if_group): Use _cpp_get_directive_token. Turn off macro expansion and line commands while skipping. Return the result of consider_directive_while_skipping, if nonzero. (do_endif): Just set potential_control_macro here. (validate_else): Use _cpp_get_directive_token. (do_assert, do_unassert): Don't save pointers into the token_buffer across calls to the lexer. Use _cpp_get_directive_token. * cpplib.h (cpp_buffer): Remove alimit and colno. Make mark a pointer, not an offset. Replace 'data', which was a generic pointer, with 'macro', which points to a struct hashnode. (cpp_reader): Add 'potential_control_macro' pointer. * cpphash.h (T_UNUSED): Replace with T_EMPTY. (CPP_BUF_GET, CPP_FORWARD): Delete. (CPP_IN_COLUMN_1, ADJACENT_TO_MARK): New macros. (CPP_IS_MACRO_BUFFER, CPP_SET_BUF_MARK, CPP_GOTO_BUF_MARK, ACTIVE_MARK_P): Update. (_cpp_get_define_token): New internal function. * cppfiles.c (read_include_file): Don't set fp->alimit or fp->colno. From-SVN: r32965
2000-04-05cpphash.c (_cpp_free_definition): Test argnames, not nargs >= 0, before ↵Philippe De Muyter1-1/+1
freeing argnames. 2000-04-04 Philippe De Muyter <phdm@macqel.be> * cpphash.c (_cpp_free_definition): Test argnames, not nargs >= 0, before freeing argnames. * cpplib.c (do_ifndef): Cast return value of xstrdup. From-SVN: r32924
2000-04-01cpplib.c: Include symcat.h.Zack Weinberg1-2/+2
* cpplib.c: Include symcat.h. Add 'origin' field to struct directive. Add origin values to DIRECTIVE_TABLE. Generate the strings and function names on the fly. Take the #sccs entry out of the table if SCCS_DIRECTIVE is not defined. (_cpp_handle_directive): Decide if the # was at the beginning of the line here. Issue -pedantic warnings for extended directives here. Warn about K+R directives with the # indented, and C89/extended directives with the # not indented, here. (do_import, do_include_next, do_warning, do_ident, do_sccs, do_assert, do_unassert): Don't issue pedantic warning here. * cpphash.h: Add CPP_WTRADITIONAL macro. * cpplib.h (struct cpp_options): Rename warn_stringify to warn_traditional; update comments. * cppinit.c (handle_option): Set warn_traditional not warn_stringify. * cpphash.c: Replace CPP_OPTION (pfile, warn_stringify) with CPP_WTRADITIONAL (pfile). * cpplex.c (_cpp_lex_token): Don't decide if directives should be ignored in -traditional mode here. * cpplex.c: Copy ISTABLE macros from cppinit.c, and adapt them to initialize speccase[] and trigraph_map[]. Delete all references to pfile->input_speccase. Always treat '?' as a special character. Remove table-initialization code from _cpp_init_input_buffer. * cpplib.h (struct cpp_reader): Remove input_speccase field. * cppinit.c (cpp_cleanup): Don't free input_speccase. From-SVN: r32860