summaryrefslogtreecommitdiffstats
path: root/gcc/cpphash.c
Commit message (Collapse)AuthorAgeFilesLines
* * cpperror.c: Fix formatting.kazu2002-05-221-1/+1
| | | | | | | | | | | | | | | | * cppexp.c: Likewise. * cppfiles.c: Likewise. * cpphash.c: Likewise. * cpphash.h: Likewise. * cppinit.c: Likewise. * cpplex.c: Likewise. * cpplib.c: Likewise. * cppmacro.c: Likewise. * cppmain.c: Likewise. * cppspec.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53751 138bc75d-0d04-0410-961f-82ee72b054a4
* * c-common.c (c_common_init): Set options->unsigned_char fromzack2002-05-211-1/+0
| | | | | | | | | | | | | | | | | | | flag_signed_char. (cb_register_builtins): Define __STRICT_ANSI__ and __CHAR_UNSIGNED__ here... * cppinit.c (init_builtins): Not here. (cpp_create_reader): unsigned_char option defaults to 0, not !DEFAULT_SIGNED_CHAR. (COMMAND_LINE_OPTIONS, cpp_handle_option): Lose -fsigned-char and -funsigned-char. * cpphash.h (struct spec_nodes): Kill n__STRICT_ANSI__. * cpphash.c (_cpp_init_hashtable): Don't set it. * cppmacro.c (builtin_macro) [BT_STDC]: Use the language setting directly. Clarify comment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53703 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.h (struct spec_nodes): Remove n__CHAR_UNSIGNED__.neil2002-02-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * cpphash.c (_cpp_init_hashtable): Similarly. * cppinit.c (cpp_create_reader): Default the signed_char flag. (init_builtins): Define __CHAR_UNSIGNED__ appropriately. (COMMAND_LINE_OPTIONS): Recognise -f{un,}signed-char. (cpp_handle_option): Handle the new options. * cpplex.c (cpp_interpret_charconst): Use new flag. * cpplib.h (struct cpp_options): New member signed_char. * gcc.c (cpp_unique_options): Remove %c spec and documentation. (cpp_options): Handle -fsigned-char and -funsigned-char. (static_specs): Remove signed_char_spec. (do_spec1): Don't handle %c. * system.h: Poison SIGNED_CHAR_SPEC. * tradcif.y (yylex): Use flag_signed_char. * tradcpp.h (flag_signed_char): New. * tradcpp.c (flag_signed_char): New. (main): Handle new command-line options. (initialize_builtins): Define __CHAR_UNSIGNED__ if appropriate. config: * alpha/alpha.h (SIGNED_CHAR_SPEC): Remove. * avr/avr.h: Remove old comments. * i960/i960.h (CPP_SPEC): Pass -fsigned-char if -mic*. (CC1_SPEC): Pass -fsigned-char if -mic*. (SIGNED_CHAR_SPEC): Remove. doc: * tm.texi (SIGNED_CHAR_SPEC): Remove documentation. testsuite: * gcc.dg/cpp/uchar-1.c, uchar-2.c, uchar-3.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49444 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpperror.c: Update comments and copyright.neil2002-01-031-7/+1
| | | | | | | | * cppexp.c, cppfiles.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c, cpplib.c, cpplib.h, cppmacro.c, cppmain.c: Similarly. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48522 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (_cpp_init_hashtable): Update.neil2001-11-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | * cpphash.h (struct spec_nodes): Remove n_L. * cpplex.c (_cpp_lex_direct): Check for prefix L separately. * Makefile.in: Update, and add c-objc-common.o dependencies. * c-lang.c: Remove unnecessary includes. (c_init): Move bulk of code to c_objc_common_init, and call it. (c_tree_printer, c_missing_noreturn_ok_p, c_disregard_inline_limits, inline_forbidden_p, c_cannot_inline_tree_fn): Move to c-objc-common.c. * c-objc-common.c: New. Mostly pulled from c-lang.c. * c-tree.h (c_disregard_inline_limits, c_cannot_inline_fn, c_objc_common_init, c_missing_noreturn_ok_p): New. * toplev.c: Update comment. * doc/passes.texi: Update. * objc/ojbc-act.c (LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN, LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS, LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P): Override. (objc_init): Update to use c_objc_common_init. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47388 138bc75d-0d04-0410-961f-82ee72b054a4
* * c-common.c: Include c-lex.h.neil2001-11-151-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47046 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (_cpp_destroy_hashtable): Use ht_destroy.neil2001-08-111-1/+1
| | | | | | | | | | | | | | | | * cpphash.h (CPP_IN_SYSTEM_HEADER): Fix. (struct cpp_pool): New member first. * cppinit.c (append_include_chain): Plug memory leaks. * cpplib.c (cpp_register_pragma, cpp_register_pragma_space): Allocate pragma structures from the (aligned) macro pool to avoid leaking memory. * cpplex.c (_cpp_init_pool, _cpp_free_pool): Use pool->first so we don't leak memory. * hashtable.c (ht_destroy): New. * hashtable.h (ht_destroy): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44794 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (alloc_node): Cast pointer.neil2001-05-301-1/+2
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42720 138bc75d-0d04-0410-961f-82ee72b054a4
* * Makefile.in (OBJS, LIBCPP_OBJS, LIBCPP_DEPS,neil2001-05-201-227/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cpplib.o, cpphash.o, fix-header): Update. (hashtable.o): New target. * c-common.h: Include cpplib.h. Define C_RID_CODE and struct c_common_identifier here. * c-lang.c (c_init_options): Update. Call set_identifier_size. * c-lex.c (c_lex): Update. * c-pragma.h: Update. * c-tree.h (struct lang_identifier): Contain c_common_identifier. Delete rid_code. (C_RID_CODE): Delete. * cpphash.c: Rewrite to use hashtable.c. * cpphash.h: Update include guards. (struct cpp_reader): Remove hashtab. hash_ob and buffer_ob are no longer pointers. Add hash_table and our_hashtable. (HASHSTEP, _cpp_init_hashtable, _cpp_lookup_with_hash): Delete. (_cpp_cleanup_hashtable): Rename _cpp_destroy_hashtable. (_cpp_cleanup_stacks): Rename _cpp_init_directives. * cppinit.c (cpp_create_reader): Update. * cpplex.c (cpp_ideq, parse_identifier, cpp_output_token): Update. (cpp_interpret_charconst): Eliminate warning. * cpplib.c (do_pragma, do_endif, push_conditional, cpp_push_buffer, cpp_pop_buffer): Update. (_cpp_init_stacks): Rename cpp_init_directives. (_cpp_cleanup_stacks): Remove. * cpplib.h: Update include guards. Include tree-core.h and c-rid.h. (cpp_hashnode, cpp_token, NODE_LEN, NODE_NAME, cpp_forall_identifiers, cpp_create_reader): Update. (C_RID_CODE, cpp_make_node): New. (c_common_identifier): New identifier node for C front ends. * cppmain.c (main): Update. * fix-header.c (read_scan_file): Update. * flags.h (id_clash_len): Make unsigned. * ggc.h (ggc_mark_nonnull_tree): New. * hashtable.c: New. * hashtable.h: New. * stringpool.c: Update comments and copyright. Update to use hashtable.c. * toplev.c (approx_sqrt): Move to hashtable.c. (id_clash_len): Make unsigned. * toplev.h (ident_hash): New. * tree.c (gcc_obstack_init): Move to hashtable.c. * tree.h: Include hashtable.h. (IDENTIFIER_POINTER, IDENTIFIER_LENGTH): Update. (GCC_IDENT_TO_HT_IDENT, HT_IDENT_TO_GCC_IDENT): New. (struct tree_identifier): Update. (make_identifier): New. cp: * cp-tree.h (struct lang_identifier, C_RID_YYCODE): Update. (C_RID_CODE): Remove. * lex.c (cxx_init_options): Call set_identifier_size. Update. (init_parse): Don't do it here. objc: * objc-act.c (objc_init_options): Call set_identifier_size. Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42334 138bc75d-0d04-0410-961f-82ee72b054a4
* * cppexp.c (lex): Use NODE_NAME and NODE_LEN.neil2001-05-161-6/+6
| | | | | | | | | | | | | | | | | | | * cpphash.c (_cpp_lookup_with_hash): Similarly. * cpplex.c (cpp_ideq, parse_identifier, cpp_token_len, cpp_spell_token, cpp_output_token): Similarly. * cpplib.c (lex_macro_node, do_undef, do_pragma, do_pragma_poison, parse_assertion, do_assert): Similarly. * cppmacro.c (builtin_macro, parse_args, funlike_invocation_p, save_parameter, _cpp_create_definition, check_trad_stringification, cpp_macro_definition): Similarly. * cppmain.c (cb_define, cb_undef, dump_macro): Similarly. * c-lex.c (cb_undef, c_lex): Similarly. * fix-header.c (recognized_function): Similarly. * cpplib.h (NODE_LEN, NODE_NAME): New. (cpp_hashnode): Rename length len. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42174 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (_cpp_cleanup_hashtable, _cpp_lookup_with_hash)neil2001-01-281-5/+1
| | | | | | | | | | | | | | | | | : 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39318 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c: Move cpp_defined here from cpplib.c.neil2000-11-091-0/+13
| | | | | | | | | | * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37345 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (cpp_forall_identifiers): Add context variablegeoffk2000-10-291-3/+4
| | | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37119 138bc75d-0d04-0410-961f-82ee72b054a4
* 2000-10-28 Neil Booth <neilb@earthling.net>neil2000-10-281-40/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37098 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.h (HASHSTEP): Take character rather than pointerneil2000-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36509 138bc75d-0d04-0410-961f-82ee72b054a4
* 2000-02-17 Zack Weinberg <zack@wolery.cumb.org>zack2000-07-181-641/+173
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35113 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (save_expansion): Clear PREV_WHITE on tokenszack2000-07-151-0/+7
| | | | | | | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35052 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (struct macro_info): Add new members.neil2000-07-131-153/+146
| | | | | | | | | | | | | | | | (_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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35025 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (macro_info): Don't use the `signed' keyword.ghazi2000-07-131-1/+1
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35023 138bc75d-0d04-0410-961f-82ee72b054a4
* * cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,zack2000-07-131-24/+18
| | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35003 138bc75d-0d04-0410-961f-82ee72b054a4
* * cppexp.c (LOGICAL): Delete macro.zack2000-07-121-5/+7
| | | | | | | | | | | | | | (_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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34994 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.h: (TOKEN_SPELL) Pulled from cpplex.c.neil2000-07-121-89/+151
| | | | | | | | | | | | | | | | | * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34985 138bc75d-0d04-0410-961f-82ee72b054a4
* 2000-07-11 Zack Weinberg <zack@wolery.cumb.org>zack2000-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34972 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpplib.h (struct cpp_name): Now struct cpp_string.zack2000-07-081-34/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34926 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (is__va_args__): New function.neil2000-07-081-29/+56
| | | | | | | | | | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34919 138bc75d-0d04-0410-961f-82ee72b054a4
* toplevel:zack2000-07-051-44/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34870 138bc75d-0d04-0410-961f-82ee72b054a4
* top level:zack2000-07-041-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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34859 138bc75d-0d04-0410-961f-82ee72b054a4
* * cppfiles.c: Include splay-tree.h, not hashtab.h.zack2000-06-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34636 138bc75d-0d04-0410-961f-82ee72b054a4
* * cppfiles.c: Read files in, using mmap if possible, thenzack2000-05-281-29/+29
| | | | | | | | | | | | | | | | | | | | | 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 *. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34228 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (funlike_macroexpand): Make sure not to walk p1zack2000-05-191-3/+3
| | | | | | | past l1 when deleting whitespace and markers. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34027 138bc75d-0d04-0410-961f-82ee72b054a4
* * cppexp.c (parse_assertion): New.zack2000-05-181-21/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33984 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (trad_stringify, warn_trad_stringify,neil2000-05-141-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33901 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (collect_funlike_expansion): Make "# is notzack2000-05-111-1/+16
| | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33841 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.h (struct hashnode): Use struct hack for namezack2000-05-101-11/+21
| | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33828 138bc75d-0d04-0410-961f-82ee72b054a4
* gcc:zack2000-05-041-28/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33657 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpplib.h: Add accessor macros for token lists.zack2000-05-031-38/+34
| | | | | | | * cpplib.c, cpphash.c, cpplex.c: Use them. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33630 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (collect_params): Fix off-by-one error.zack2000-05-021-2/+3
| | | | | | | (dump_hash_helper): Dump all four macro nodetypes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33613 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (trad_stringify): Adjust p after stringification asjakub2000-05-021-0/+1
| | | | | | | | | well. * gcc.dg/cpp-tradstringify.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33612 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpplib.h (CPP_POP, parse_cleanup_t): Delete.zack2000-05-021-28/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33611 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (_cpp_make_hashnode): Rename make_HASHNODE, nowzack2000-05-011-29/+17
| | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33581 138bc75d-0d04-0410-961f-82ee72b054a4
* * cppfiles.c (redundant_include_p): Provide length of token tozack2000-04-301-27/+5
| | | | | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33551 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.h (enum node_type: Take out T_MCONST.zack2000-04-301-122/+168
| | | | | | | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33538 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.h: Move struct reflist, struct definition, and thezack2000-04-291-21/+69
| | | | | | | | | | | | | 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33536 138bc75d-0d04-0410-961f-82ee72b054a4
* 2000-04-25 Zack Weinberg <zack@wolery.cumb.org>zack2000-04-251-6/+7
| | | | | | | | | | | | | | | | | | * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33419 138bc75d-0d04-0410-961f-82ee72b054a4
* * Revert previous patch until build failure cause determined.neil2000-04-251-6/+5
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33411 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c: replace HSPACE_BEFORE with PREV_WHITESPACE.neil2000-04-241-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33390 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (collect_objlike_expansion): Add sanity check.zack2000-04-231-23/+19
| | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33360 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.h (struct definition): Move file, line, col members...zack2000-04-231-507/+719
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33355 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (trad_stringify, add_pat): New functions.zack2000-04-221-37/+147
| | | | | | | | | | | | | | | | | (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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33350 138bc75d-0d04-0410-961f-82ee72b054a4
* * cpphash.c (struct arg, struct arglist): Const-ify strings.zack2000-04-211-405/+266
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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". git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33309 138bc75d-0d04-0410-961f-82ee72b054a4
OpenPOWER on IntegriCloud