aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
AgeCommit message (Collapse)AuthorFilesLines
2000-12-01cppinit.c (initialize): Forgotten prototype.Neil Booth1-8/+10
* cppinit.c (initialize): Forgotten prototype. * cpplex.c (_cpp_lex_token): Loop until not skipping. Always clear PREV_WHITE upon meeting a new line. * cpplib.c (end_directive): Set pfile->skipping after skip_rest_of_line. * cpplib.h (cpp_reader): Remove macro_pos. * cppmacro.c (cpp_get_line): Don't do anything special inside macros. (parse_arg): Add PREV_WHITE if a token appears after new lines. (funlike_invocation_p): Save and restore the output position over a successful check for a '('. (enter_macro_context): Delete uses of macro_pos. (cpp_get_token): Don't use pfile->skipping. From-SVN: r37927
2000-11-26cpplib.h (struct cpp_reader): Remove lang_asm.Neil Booth1-6/+4
* cpplib.h (struct cpp_reader): Remove lang_asm. (struct cpp_options): Remove c89. New members lang, extended_numbers. * cppexp.c (parse_number): Use them. * cpphash.h (VALID_SIGN): Use them. * cppinit.c (set_lang, cpp_start_read): Update. * cpplex.c (parse_string, _cpp_lex_token): Update. * cpplib.c (_cpp_handle_directive): Update. * cppmacro.c (parse_args): Update. * cppmain.c (scan_buffer): Update. From-SVN: r37761
2000-11-22cpplex.c (trigraph_ok): Ensure we don't warn twice.Neil Booth1-3/+7
* cpplex.c (trigraph_ok): Ensure we don't warn twice. * cpplib.h (struct cpp_buffer): New member last_Wtrigraphs. From-SVN: r37669
2000-11-14cppexp.c (parse_defined): Call cpp_get_token not _cpp_get_token.Neil Booth1-2/+2
* cppexp.c (parse_defined): Call cpp_get_token not _cpp_get_token. (lex): Similarly. * cpplex.c (cpp_output_line): Similarly. * cpplib.c (glue_header_name, do_line, do_ident, parse_answer, parse_assertion): Similarly. (_cpp_handle_diretive): Don't save to lookaheads when processing directives. * cppmacro.c (parse_arg, expand_arg): Call cpp_get_token not _cpp_get_token. (funlike_invocation_p): Don't save to lookaheads when pre-expanding arguments. (_cpp_get_token): Delete. (cpp_get_token): Merge contents of _cpp_get_token. From-SVN: r37462
2000-11-13cpplex.c (_cpp_lex_token): CPP_COMMENT and true CPP_EOF cases return without ↵Neil Booth1-6/+6
MI check. * cpplex.c (_cpp_lex_token): CPP_COMMENT and true CPP_EOF cases return without MI check. * cpplib.c (do_diagnostic): Take boolean of whether to print the directive name. (do_error, do_warning): Update. (do_pragma_dependency): Use it. * cpplib.h (VARARGS_FIRST): Delete. (struct cpp_token): Delete integer. * cppmacro.c (enter_macro_context): Move disabled check to _cpp_get_token. (_cpp_get_token): Simplify into a single loop. From-SVN: r37434
2000-11-12cppexp.c: Don't worry about pfile->skipping.Neil Booth1-0/+7
* cppexp.c: Don't worry about pfile->skipping. * cpplib.c (struct if_stack): Make was_skipping unsigned char. (cpp_handle_directive): Save pfile->skipping in struct cpp_buffer for handled directives. (skip_rest_of_line): Use _cpp_lex_token after popping contexts and releasing lookaheads. (do_ifdef, do_ifndef, do_if): Use buffer->was_skipping. (do_else, do_elif, push_conditional): Update logic. (do_endif): Set buffer->was_skipping rather than pfile->skipping. (unwind_if_stack): Inline into cpp_pop_buffer. (cpp_push_buffer): Clear ifs->was_skipping for cpp_handle_directive. * cpplex.c (_cpp_lex_token): Clear skipping on EOF. Handle multiple-include optimisation. * cpplib.h (struct cpp_buffer): New member was_skipping. * cppmacro.c (_cpp_get_token): Loop whilst pfile->skipping. This works because skipping == 0 in directives. (_cpp_release_lookahead): Renamed from release_lookahead. (cpp_get_token): No need to check skipping as _cpp_get_token does this for us. No need to handle MI optimisation. From-SVN: r37404
2000-11-11Remove CPP_PLACEMARKERsNeil Booth1-5/+5
* cppexp.c (lex): Don't handle CPP_PLACEMARKER. * cpplex.c (_cpp_lex_token): Rename skip_newlines to next_bol * cpplib.c (skip_rest_of_line, check_eol, cpp_push_buffer): Similarly. * cpplib.h: Remove CPP_PLACEMARKER. (struct lexer_state): Rename skip_newlines to next_bol. * cppmacro.c (stringify_arg): Don't handle CPP_PLACEMARKER. Simplify prev_white handling as a result. (paste_all_tokens): Don't worry about CPP_PLACEMARKERs. (parse_arg): Empty arguments are now empty, not CPP_PLACEMARKERs. (parse_args): Similarly. Update argument count tests. (enter_macro_context): Return 2 to indicate an empty macro. (replace_args): Don't bother pre-expanding an empty argument. Handle placemarkers and ## extension during pre-expansion. (cpp_get_token): Handle empty macro expansions. Don't worry about CPP_PLACEMARKERs. (_cpp_create_definition): Empty macros are now empty. (cpp_macro_defintion): Don't special case empty macros. * scan-decls.c: Don't bother with CPP_PLACEMARKERs. * c-lex.c: Similarly. From-SVN: r37385
2000-11-09cpphash.c: Move cpp_defined here from cpplib.c.Neil Booth1-29/+22
* 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-11-08Move directive handling into the lexer itself.Neil Booth1-5/+38
* cpplex.c (_cpp_lex_token): Handle directives directly. In the case of a directive interrupting a function-like macro invocation, use extra_char since read_ahead is used to store the '#'. Return a CPP_EOF in this case. * cppmacro.c (parse_arg): No need to handle CPP_DHASH any more. (cpp_get_token): Don't handle directives here. * cpplib.h: Remove CPP_DHASH token type. From-SVN: r37329
2000-11-06cpplex.c (_cpp_equiv_tokens): Check arg_no in the CPP_MACRO_ARG case.Neil Booth1-1/+1
* cpplex.c (_cpp_equiv_tokens): Check arg_no in the CPP_MACRO_ARG case. From-SVN: r37277
2000-11-06c-lex.c (c_lex): Replace tok.val.aux with tok.val.c or tok.val.arg_no as ↵Neil Booth1-7/+7
appropriate. * c-lex.c (c_lex): Replace tok.val.aux with tok.val.c or tok.val.arg_no as appropriate. * cppexp.c (lex): Similarly. * cpplex.c (_cpp_lex_token, cpp_spell_token, cpp_output_token, cpp_equiv_tokens, cpp_can_paste, cpp_avoid_paste): Similarly. * cppmacro.c (stringify_arg, replace_args, lex_expansion_token, cpp_macro_definition): Similarly. * cpplib.h (struct cpp_token): Replace aux with c and arg_no. From-SVN: r37276
2000-11-04cpplex.c (parse_string): Don't allow multiline strings in #include family ↵Neil Booth1-2/+2
directives. * cpplex.c (parse_string): Don't allow multiline strings in #include family directives. From-SVN: r37250
2000-11-01c-parse.in (_yylex): Remove CPP_BACKSLASH case.Neil Booth1-1/+1
* c-parse.in (_yylex): Remove CPP_BACKSLASH case. * cp/spew.c: Similarly. * cpplex.c (_cpp_lex_token): Backslashes are now CPP_OTHER. * cppmacro.c (stringify_arg): Similarly. * cpplib.h (CPP_BACKSLASH): Delete. From-SVN: r37182
2000-10-30cppfiles.c (stack_include_file): Check for stacked contexts here.Neil Booth1-49/+55
* cppfiles.c (stack_include_file): Check for stacked contexts here. * cpphash.h (_cpp_do__Pragma): New prototype. * cppinit.c (cpp_reader_init): Add _Pragma keyword to hash table. * cpplex.c (skip_escaped_newlines): Only process trigraphs and escaped newlines if !(buffer->from_stage3). (_cpp_lex_token): Warn about missing newlines iff !buffer->from_stage3. * cpplib.c (get__Pragma_string, destringize, _cpp_do__Pragma): New functions. (run_directive): Set output_line for _Pragma to avoid line markers in output. Set from_stage3 and prevent macro expansion for _Pragma and command-line options. Check buffer exhaustion. (cpp_push_buffer): Don't check for stacked macro contexts, as this is perfectly legitimate for _Pragma. Move the check to stack_include_file instead. Set from_stage3 iff buffer is preprocessed input. * cpplib.h (struct cpp_buffer): Make warned_cplusplus_comments unsigned. New boolean from_stage3. (struct spec_nodes): Add n__Pragma. * cppmacro.c (enter_macro_context): Flip sense of return value. (_cpp_get_token): Handle _Pragma operator. From-SVN: r37147
2000-10-29* cpplex.c (save_comment): Don't store new lines in C++ comments.Neil Booth1-0/+4
From-SVN: r37122
2000-10-28New macro expander.Neil Booth1-1881/+519
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-28cpperror.c (_cpp_begin_message): Do the test for suppression of warnings and ↵Neil Booth1-9/+8
pedantic warnings before the "is a... * cpperror.c (_cpp_begin_message): Do the test for suppression of warnings and pedantic warnings before the "is a warning an error" tests. * cppinit.c (cpp_handle_option): Remove surplus \n. * cpplex.c (ON_REST_ARG): Delete. (skip_block_comment): Initialise prevc. (parse_args): Improve error messages. (maybe_paste_with_next): Use CONTEXT_VARARGS rather than ON_REST_ARG. * cpplib.c (cpp_push_buffer): Fix grammar in message. * cppmain.c (main): Set callbacks for #ident and #pragma only if no_output option is false. (do_pragma_implementation): Only call the #pragma handler if it is set in the cpp_reader structure. From-SVN: r36655
2000-09-25cpplex.c (parse_args): Don't set VOID_REST flag.Neil Booth1-25/+12
* cpplex.c (parse_args): Don't set VOID_REST flag. (Fix diagnostic merge problem). (CONTEXT_VARARGS): New flag. (maybe_paste_with_next): Set context earlier in loop. Use it. Do varargs test with CONTEXT_VARARGS flag. (push_arg_context): Set CONTEXT_VARARGS flag if we're pushing an argument context for a varargs argument. * cpplib.h (VOID_REST): Delete. * gcc.dg/cpp/vararg1.c: Add test case. From-SVN: r36638
2000-09-25flags.h: Declare warning flag warn_system_headers.Branko Cibej1-3/+17
2000-09-25 Branko Cibej <branko.cibej@hermes.si> * flags.h: Declare warning flag warn_system_headers. * toplev.c: Define it. (W_options): Add option -Wsystem-headers. * diagnostic.c (count_error): Test warn_system_headers. * invoke.texi: Add description for -Wsystem-headers. * cpplib.h (cpp_options): New member warn_system_headers. * cpphash.h (CPP_PEDANTIC, CPP_WTRADITIONAL): Don't test CPP_IN_SYSTEM_HEADER. * cpplib.c (do_import, do_pragma_once): Likewise. * cpperror.c (_cpp_begin_message): Test warn_system_headers and CPP_IN_SYSTEM_HEADER. * cppinit.c (handle_option): Recognize -Wsystem_headers. (print_help): Describe -Wsystem_headers. * cpplex.c (lex_line): Reorganize condition so that warnings about C++ comments in system headers can be enabled. Remove label do_line_comment. From-SVN: r36636
2000-09-25cpplex.c (save_comment): Only store the initial '/' now.Neil Booth1-47/+35
* cpplex.c (save_comment): Only store the initial '/' now. (lex_token): Combine handling of the two comment types. Pass everything but the initial '/' to save_comment. From-SVN: r36635
2000-09-25cpphash.h (_cpp_digraph_spellings, [...]): New library-internal prototypes.Neil Booth1-327/+9
* cpphash.h (_cpp_digraph_spellings, _cpp_process_directive, _cpp_can_paste): New library-internal prototypes. * cpplex.c (dump_param_spelling, output_line_command, output_token, cpp_scan_buffer, cpp_scan_buffer_nooutput, cpp_printf, cpp_output_list): Move to cppoutput.c. (process_directive, can_paste, digraph_spellings): Add _cpp_ prefix. * cppmacro.c (dump_macro_args, cpp_dump_definition) Move to cppoutput.c. * cppoutput.c (dump_macro_args, cpp_dump_definition, output_token, dump_param_spelling, output_line_command, cpp_scan_buffer, cpp_scan_buffer_nooutput, cpp_printf, cpp_output_list): Moved from elsewhere. * Makefile.in: Add cppoutput.c. * po/POTFILES.in: Add cppoutput.c. From-SVN: r36634
2000-09-24cpplex.c: Update TODO comment.Neil Booth1-3/+0
* cpplex.c: Update TODO comment. * cpplib.c (do_error, do_warning): Merge common code of do_error and do_warning into do_diagnostic. Use it. (do_diagnostic): New function. * cpplib.h: Fix comment typo. From-SVN: r36587
2000-09-23cpphash.h (CPP_RESERVE, [...]): Delete.Neil Booth1-105/+122
* cpphash.h (CPP_RESERVE, CPP_PUTS_Q, CPP_PUTS, CPP_PUTC_Q, CPP_PUTC, DUMMY_TOKEN, NO_DUMMY_TOKEN): Delete. * cpplex.c (_cpp_expand_token_space, _cpp_init_toklist, _cpp_free_toklist): No need to worry about extra dummy token at the start of token lists any more. (trigraph_ok): Only warn outside comments. (skip_block_comment): Set and clear lexing_comment. (skip_line_comment): Take a cpp_reader not cpp_buffer. Set and clear lexing_comment. (parse_number): Handle leading '.' indicated by pfile->seen_dot. (check_long_token): Delete. (lex_percent, lex_dot): New subroutines of lex_token to handle lexing of '.' and '%' without lookback. (lex_token): Use lex_dot and lex_percent. (lex_line): Don't check for LIST_OFFSET. (_cpp_init_input_buffer): Update for new _cpp_init_toklist. * cpplib.c (_cpp_parse_assertion): Similarly. (cpp_push_buffer): Initialize extra_char. * cpplib.h (LIST_OFFSET): Delete. (struct cpp_buffer): New member extra_char. (struct lexer_state): New members lexing_comment and seen_dot. From-SVN: r36582
2000-09-19cpplex.c (lex_line): Drop the EOF token for unknown directives in assembler.Neil Booth1-5/+5
* cpplex.c (lex_line): Drop the EOF token for unknown directives in assembler. From-SVN: r36545
2000-09-18cpphash.h (HASHSTEP): Take character rather than pointer to character.Neil Booth1-1055/+920
* 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-09-16cpplex.c (push_macro_context): Set an argument's level after calling parse_args.Neil Booth1-1/+2
* cpplex.c (push_macro_context): Set an argument's level after calling parse_args. We could loop infinitely otherwise. * gcc.dg/cpp/macro2.c: New testcase. From-SVN: r36452
2000-09-15cpplex.c (ON_REST_ARG): Correct the test.Neil Booth1-5/+8
* cpplex.c (ON_REST_ARG): Correct the test. (maybe_paste_with_next): Duplicate a token that fail pasting, and clear its PASTE_LEFT flag, so that nested pasting attempts do not occur. * gcc.dg/cpp/paste10.c: Testcase. From-SVN: r36424
2000-09-12cppfiles.c: Move all default-#defines to top of file.Zack Weinberg1-32/+40
* cppfiles.c: Move all default-#defines to top of file. (open_include_file): Replace by lookup_include_file. (read_with_read, read_file): Merged into read_include_file. (stack_include_file, purge_cache): New functions. (close_cached_fd): Delete. (lookup_include_file, read_include_file, _cpp_pop_file_buffer): Cache the in-memory buffer, not the file descriptor. * cpphash.h (struct include_file): Add buffer, st, refcnt, mapped fields. (xcnew): New utility macro. (DO_NOT_REREAD, NEVER_REREAD): Move up by struct include_file. * cpplib.h (struct cpp_buffer): Remove mapped field. * cpplex.c (parse_string): Accept backslash space newline as a line continuation. (lex_line): Likewise. (_cpp_get_token): Remove hard limit on macro nesting. testsuite: * gcc.dg/cpp/backslash.c: New test. From-SVN: r36347
2000-09-04cpplex.c (ON_REST_ARG): Check VAR_ARGS flag of current context, use posn - 1 ↵Jakub Jelinek1-3/+3
to index into tokens array. * cpplex.c (ON_REST_ARG): Check VAR_ARGS flag of current context, use posn - 1 to index into tokens array. (maybe_paste_with_next): Adjust caller. * gcc.dg/cpp/paste8.c: New test. From-SVN: r36128
2000-08-29cpperror.c (print_file_and_line): If line is (unsigned int)-1, print just ↵Zack Weinberg1-1/+8
the filename. * cpperror.c (print_file_and_line): If line is (unsigned int)-1, print just the filename. * cpplex.c (_cpp_run_directive): Add additional argument, the name to give the synthetic buffer. This defaults to translated "<command line>". * cpplib.c (cpp_define, cpp_undef, cpp_assert, cpp_unassert): Adjust to match. (_cpp_define_builtin): New function. * cppinit.c (initialize_builtins): Use _cpp_define_builtin. * cpphash.h: Update prototypes. * tradcpp.c (main): Process -D and -U simultaneously, in the order they appeared on the command line. From-SVN: r36043
2000-08-28cpplex.c (parse_string): Don't look for backslash before first char in ↵Greg McGary1-1/+1
`namebuf'. * cpplex.c (parse_string): Don't look for backslash before first char in `namebuf'. * loop.c (strength_reduce): Skip NOTEs. From-SVN: r36015
2000-08-25cpplex.c (is_macro_disabled): Caller has already checked that we're not a ↵Neil Booth1-4/+0
preprocessed file. * cpplex.c (is_macro_disabled): Caller has already checked that we're not a preprocessed file. From-SVN: r35970
2000-08-23cpphash.h (IN_I): New flag for directive table.Zack Weinberg1-0/+5
* cpphash.h (IN_I): New flag for directive table. * cpplib.c (DIRECTIVE_TABLE): Mark #define, #undef, #ident, and #pragma with IN_I. (_cpp_check_directive): If -fpreprocessed, execute directives marked with IN_I. Issue no warnings in this case. * cpplex.c (_cpp_get_token): Expand no macros if -fpreprocessed. From-SVN: r35918
2000-08-20[multiple changes]Zack Weinberg1-4/+7
2000-08-20 Zack Weinberg <zack@wolery.cumb.org> * cppinit.c (cpp_init): Set global flag when called. (cpp_reader_init): Bomb out if cpp_init hasn't been called. Sun Aug 20 01:41:35 MSD 2000 Dennis Chernoivanov <cdi@sparc.spb.su> * cpplex.c (cpp_scan_buffer): Move `output_line_command' just before `process_directive' so that newlines won't be missed for directives. (cpp_printf): Increment `print->lineno' when newline is emitted. * cppmain.c (cb_ident): Likewise. (cb_define): Likewise. (cb_undef): Likewise. (cb_include): Likewise. (cb_def_pragma): Likewise. (dump_macros_helper): Likewise. * gcc.dg/cpp/pragma-1.c: New test. * gcc.dg/cpp/pragma-2.c: New test. From-SVN: r35825
2000-08-18cpphash.h: Use HAVE_DESIGNATED_INITIALIZERS.Neil Booth1-36/+6
* cpphash.h: Use HAVE_DESIGNATED_INITIALIZERS. (_cpp_trigraph_map): Declaration moved from cpplex.c * cppinit.c: Define _cpp_trigraph_map. Use UCHAR_MAX + 1 instead of 256. Use consistent test for designated initializers. (cpp_init): Initialize trigraph_map. (initialize_standard_includes, parse_option): Use memcmp instead of strncmp. * cpplex.c (init_trigraph_map): Remove. (trigraph_ok, trigraph_replace, lex_line): Refer to _cpp_trigraph_map. * cpplib.c (str_match, WARNING, ERROR, ICE): Delete. (do_unassert): Remove unused "next" local. * system.h (HAVE_DESIGNATED_INITIALIZERS): New prototype. From-SVN: r35789
2000-08-09configure.in (--enable-c-cpplib): Uncomment.Zack Weinberg1-1/+6
* configure.in (--enable-c-cpplib): Uncomment. Use AC_DEFINE instead of extra_c_flags. (--enable-c-mbchar): Use AC_DEFINE instead of extra_c_flags. * configure: Regenerate. * config.in: Regenerate. * cpperror.c (cpp_type2name): New function. * cpplex.c (lex_line): If we issued an error for an invalid preprocessing directive, discard that logical line. * cpplib.c (do_line): Call a hook function if the current file is renamed by #line. (do_ident): Pass the contents of the string, not the entire token, to the callback function. * cpplib.h (CPP_LAST_PUNCTUATOR): New #define. (cb.rename_file): New hook function. (cb.ident): Adjust prototype. (cpp_type2name): Prototype. * cppmacro.c (dump_macro_args): Correct precedence lossage. * cppmain.c (cb_ident): Update for changed interface. (cb_rename_file): New function. (main): Set rename callback. From-SVN: r35593
2000-08-04cpplex.c (parse_name): Might have to glue a CPP_OTHER token before the name.Zack Weinberg1-36/+75
* cpplex.c (parse_name): Might have to glue a CPP_OTHER token before the name. (lex_line): Glue @ onto the beginning of identifiers and string constants, in Objective-C mode. (output_token, spell_token): Handle CPP_OSTRING. (can_paste, maybe_paste_with_next): Handle pasting @ onto the beginning of a NAME or a STRING, in objc mode. * cpplib.c (get_define_node): Do not permit identifiers that begin with @ to be #defined. * cppmacro.c (CAN_PASTE_AFTER): Add CPP_OTHER. * cpplib.h (TTYPE_TABLE): Add CPP_OSTRING. * c-lang.c, objc/objc-act.c (build_objc_string): Delete. * c-tree.h (build_objc_string): Delete prototype. * objc/objc-tree.def: Delete OBJC_STRING_CST. * c-lex.c (yylex): Use build_string for all three kinds of strings. * gcc.dg/cpp/20000625-2.c: Don't expect a warning on line 4. From-SVN: r35470
2000-08-02cppexp.c, [...]: Do not use 'legal' or 'illegal' in error messages and comments.Zack Weinberg1-7/+23
* cppexp.c, cppinit.c, cpplex.c, cpplib.c, cppmacro.c, cppspec.c: Do not use 'legal' or 'illegal' in error messages and comments. * cppmain.c (cb_define, cb_undef): Don't generate any output if not done_initializing. * cpplex.c (maybe_paste_with_next): When the token after a ## is an omitted rest argument, only delete the token before it if that token is a comma. Do not warn about bogus token pastes for , ## rest_arg. * cpp.texi: Update. * cpp.1: Regenerate. * gcc.dg/cpp/macsyntx.c: Fix error regexp. From-SVN: r35421
2000-08-02cpperror.c (v_message): Split into _cpp_begin_message and v_message macro.Zack Weinberg1-250/+210
* cpperror.c (v_message): Split into _cpp_begin_message and v_message macro. All callers updated. (_cpp_begin_message): Do inhibit_errors/inhibit_warnings checks here. * cppfiles.c (cpp_syshdr_flags): New function. (read_include_file): Don't call cpp_output_tokens. Call enter_file hook. * cppinit.c (dump_macros_helper): Moved to cppmain.c. (cpp_reader_init): Don't initialize token_buffer. Call _cpp_init_internal_pragmas. (cpp_cleanup): Don't clear token_buffer. (cpp_start_read): Don't worry about output from -D processing. Don't call cpp_output_tokens. (cpp_finish): Don't dump macros here. Don't call cpp_output_tokens. * cppmacro.c (_cpp_dump_definition): Rename cpp_dump_definition. Write directly to a FILE *. (dump_funlike_macro): Delete. (dump_macro_args): New. * cpplex.c (TOKEN_LEN): Convert to inline function. (_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens, cpp_scan_line, _cpp_dump_list): Delete. (cpp_printf, cpp_output_list): New. (output_line_command): Don't worry about entering or leaving files. (cpp_scan_buffer): Just output each token as we hit it. (process_directive): Don't call cpp_output_tokens. (_cpp_glue_header_name): Don't use token_buffer. (output_token, dump_param_spelling): Write directly to a FILE *. * cpplib.c (pass_thru_directive, dump_macro_name, pragma_dispatch, do_pragma_gcc): Delete. (do_define, do_undef, parse_include, do_line, do_ident, do_pragma, do_pragma_poison, cpp_pop_buffer): Call the appropriate hook functions. (do_error, do_warning, pragma_dependency): Call _cpp_begin_message, then cpp_output_list. (cpp_register_pragma, cpp_register_pragma_space, _cpp_init_internal_pragmas): New. (do_pragma): Walk the pragmas table here. (do_pragma_once, do_pragma_poison, do_pragma_system_header, do_pragma_dependency): Return void. (do_pragma_implementation): Moved to cppmain.c. * cpplib.h: Update prototypes. (struct cpp_reader): Remove printer, token_buffer, token_buffer_size, and limit. Add struct cb, and pragmas. (struct cpp_printer): Remove last_id and written. (CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN, CPP_ADJUST_WRITTEN): Delete. * cpphash.h: Update prototypes. (ufputs): New wrapper. * cppmain.c (cb_define, cb_undef, cb_include, cb_ident, cb_enter_file, cb_leave_file, cb_def_pragma): New functions. (main): Set up callbacks. Register #pragma implementation. Dump macros from here. From-SVN: r35415
2000-07-31[multiple changes]Zack Weinberg1-4/+20
2000-07-31 Jakub Jelinek <jakub@redhat.com> * cpplex.c (_cpp_get_line): If index is 0, return line 0 col 0. (_cpp_get_token): Don't macro expand a just pasted token if it was pasted at no_expand_level. * testsuite/gcc.dg/cpp/paste7.c: New test. 2000-07-31 Zack Weinberg <zack@wolery.cumb.org> * cppmacro.c (find_param, count_params, save_expansion): Permit 'defined' as a macro parameter name. From-SVN: r35394
2000-07-24cppexp.c: Warn about unary + if -Wtraditional.Zack Weinberg1-4/+2
* cppexp.c: Warn about unary + if -Wtraditional. * cpplex.c (lex_line): Always set BOL on the first token of a line. From-SVN: r35239
2000-07-20cppmacro.c (CAN_PASTE_AFTER): New macro.Zack Weinberg1-23/+21
* cppmacro.c (CAN_PASTE_AFTER): New macro. (count_params): Don't set GNU_REST_ARGS on anything. (save_expansion): Set PASTE_LEFT only on tokens for which CAN_PASTE_AFTER is true, or which are named operators. * cpplex.c (parse_args): Distinguish between a rest argument given one empty argument, and a rest argument given zero arguments. (maybe_paste_with_next): Look for VOID_REST tag, and trigger deletion of previous token based on that. (get_raw_token): Flatten some control structure. * cpplib.h (CPP_LAST_EQ): Correct. (VOID_REST): New token flag. (GNU_REST_ARGS): Delete. * gcc.dg/cpp/20000625-2.c, gcc.dg/cpp/macsyntx.c: Update error regexps. * gcc.dg/cpp/paste6.c: New test. From-SVN: r35146
2000-07-19cpplib.h (TTYPE_TABLE): Move CPP_MIN and CPP_MAX into block of operators ↵Zack Weinberg1-15/+32
allowed in #if... * cpplib.h (TTYPE_TABLE): Move CPP_MIN and CPP_MAX into block of operators allowed in #if and having an _EQ variant. Add CPP_MIN_EQ, CPP_MAX_EQ, and CPP_DEFINED. (cpp_token flags): Add NAMED_OP. (enum node_type): Add T_OPERATOR. (struct cpp_hashnode): Add code slot to value union. * cpphash.h (spec_nodes): Remove n_defined. * cpplex.c (lex_line): Convert T_OPERATOR nodes to their proper types. (spell_token, can_paste, maybe_paste_with_next): Handle named operators. (is_macro_disabled): Tweak error messages. * cpplib.c (get_define_node): Disallow all named operators as macro names. Tweak error messages. (_cpp_init_stacks): Don't set up spec_nodes->n_defined. * cppinit.c (builtin_array): Add entries for the named operators. * cppexp.c (lex): Check for CPP_DEFINED token. (priority table): Add entries for CPP_MIN and CPP_MAX. (_cpp_parse_expr): Handle CPP_MIN and CPP_MAX. testsuite: * gcc.dg/cpp/directiv.c, gcc.dg/cpp/macsyntx.c, gcc.dg/cpp/undef1.c: Tweak error regexps. From-SVN: r35137
2000-07-18cpplib.h (TTYPE_TABLE): Rearrange to use only two per-entry macros, not five.Zack Weinberg1-49/+33
* cpplib.h (TTYPE_TABLE): Rearrange to use only two per-entry macros, not five. * cpphash.h (TOKEN_NAME): New macro. (_cpp_spell_operator): Deleted. (token_spellings): Now _cpp_token_spellings. * cppexp.c: Use TOKEN_NAME or TYPE_NAME, not _cpp_spell_operator. * cpplex.c: Use OP and TK macros when expanding the TTYPE_TABLE. Eliminate token_names. For non-OPERATOR tokens, store the stringification of the enumeration name (CPP_CHAR, etc.) in the name slot of token_spellings. Use TOKEN_NAME and/or TOKEN_SPELL, do not reference token_spellings directly. * cpplib.c: Use TOKEN_SPELL. * cpplex.c (_cpp_push_token): If the token being pushed back is the previous token in this context, just subtract one from context->posn. * cppmacro.c (save_expansion): Clear aux field when storing a placemarker. * gcc.dg/cpp/paste5.c: New test. * gcc.dg/cpp/vararg1.c: New test. From-SVN: r35124
2000-07-18cpplex.c (cpp_scan_buffer): Output line command even at the stop buffer, ↵Jakub Jelinek1-1/+4
provided it is not NULL. * cpplex.c (cpp_scan_buffer): Output line command even at the stop buffer, provided it is not NULL. From-SVN: r35123
2000-07-18[multiple changes]Zack Weinberg1-6/+13
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-16cpplex.c: Update comments.Neil Booth1-4/+165
* cpplex.c: Update comments. * README.Portability: Small update. From-SVN: r35058
2000-07-15cpphash.c (save_expansion): Clear PREV_WHITE on tokens immediately following ↵Zack Weinberg1-7/+34
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-13cpplex.c (adjust_column): New funcion.Neil Booth1-15/+29
* cpplex.c (adjust_column): New funcion. (skip_whitespace): Use it. (skip_block_comment): Use it, and warn about /*/* with -Wcomments. From-SVN: r35026
2000-07-13cppexp.c, [...]: Eradicate all traces of code dependent on traditional, ↵Zack Weinberg1-127/+115
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