aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
AgeCommit message (Collapse)AuthorFilesLines
2000-02-11cpphash.c: Fix formatting, update commentary.Zack Weinberg1-149/+203
* cpphash.c: Fix formatting, update commentary. (dump_definition): Take three separate arguments instead of a MACRODEF structure argument. * cpphash.h: Update prototype of dump_definition. * cppinit.c (cpp_finish): Update call of dump_definition. * cpplib.c (do_define): Always create new hash entry with T_MACRO type. Remove redundant check for redefinition of poisoned identifier. Update call of dump_definition. (do_undef): Don't call check_macro_name. Rename sym_length to len. (do_error, do_warning): Don't use copy_rest_of_line or SKIP_WHITE_SPACE. (do_warning): Don't use pedwarn for the actual warning, only the notice about its not being in the standard. (Fixes bug with #warning in system headers.) (do_ident): Stricter argument checking - accept only a single string after #ident. Also, macro-expand the line. (do_xifdef): Use cpp_defined. De-obfuscate. (do_pragma): Split out specific pragma handling to separate functions. Use get_directive_token. Update commentary. Do not pass on #pragma once or #pragma poison to the front end. (do_pragma_once, do_pragma_implementation, do_pragma_poison, do_pragma_default): New. From-SVN: r31931
2000-02-10cppexp.c: Don't include cpphash.h.Zack Weinberg1-24/+41
* cppexp.c: Don't include cpphash.h. (parse_charconst, cpp_lex): Use cpp_defined. (cpp_lex): Use get_directive_token throughout. Remove unnecessary cases from switch. Move assertion-handling code down to OTHER case. (cpp_parse_expr): If we see '+' or '-', check the context to determine if they are unary or binary operators. Streamline the jumps a bit. Do not call skip_rest_of_line. * cpplib.c: Make skip_rest_of_line and cpp_skip_hspace static. Export get_directive_token. Update commentary. (cpp_defined): New function. (do_define): Remove reference to T_PCSTRING. Call free_definition to release memory for old definition, when redefining a macro. (eval_if_expression): Set only_seen_white to 0 before calling cpp_parse_expr. Call skip_rest_of_line after it returns. (cpp_read_check_assertion): Don't preserve a pointer into the token buffer across a call to cpp_get_token. * Makefile.in (cppexp.o): Don't depend on cpphash.h. * cppfiles.c (redundant_include_p): Use cpp_defined. * cpphash.c (free_definition): New function. (delete_macro): Use it. Update commentary. * cpphash.h: Typedef HASHNODE here. Prototype cpp_lookup and free_definition. * cpplib.h: Don't typedef HASHNODE here. Delete T_PCSTRING from enum node_type. Prototype cpp_defined and get_directive_token. Don't prototype cpp_lookup, skip_rest_of_line, or cpp_skip_hspace. * fix-header.c (check_macro_names): Use cpp_defined. (read_scan_file): Set inhibit_warnings and inhibit_errors in the options structure. From-SVN: r31908
2000-02-10cpplib.h: Provide HASHNODE typedef and forward decl of struct hashnode only.Zack Weinberg1-18/+14
* cpplib.h: Provide HASHNODE typedef and forward decl of struct hashnode only. Kill cpp_hashnode typedef. MACRODEF, DEFINITION, struct hashnode, struct macrodef, struct definition, scan_decls prototype, default defn of INCLUDE_LEN_FUDGE moved elsewhere. * cpphash.h: MACRODEF, DEFINITION, struct macrodef, struct definition, and struct hashnode moved here. Remove the unused 'predefined' field from struct definition. Replace the 'args' union with its sole member. All users updated (cpphash.c). Delete HASHSTEP and MAKE_POS macros, and hashf prototype. Add multiple include guard. * cpphash.c (hashf): Make static; use better algorithm; drop HASHSIZE parameter; return an unsigned int. (cpp_lookup): Drop HASH parameter. PFILE parameter is used. Calculate HASHSIZE modulus here. (cpp_install): Drop HASH parameter. Calculate HASHSIZE modulus here. (create_definition): Drop PREDEFINITION parameter. * cpplib.c (do_define): Don't calculate a hash value here. Don't pass (keyword == NULL) to create_definition. * scan.h: Prototype scan_decls here. * cppfiles.c: Move INCLUDE_LEN_FUDGE default defn here. * cppexp.c, cppfiles.c, cppinit.c, cpplib.c, fix-header.c: All callers of cpp_lookup and cpp_install updated. From-SVN: r31881
2000-02-10cpphash.c (macarg): Hoist all the flag diddling out of the function...Zack Weinberg1-63/+62
* cpphash.c (macarg): Hoist all the flag diddling out of the function... (macroexpand): ... and out of the loop that calls macarg. Skip over the initial paren before macro arguments with cpp_get_non_space_token; point may be some distance before that paren. Abort if it's not there. * cpplib.c (parse_clear_mark): Delete function. (parse_set_mark, parse_goto_mark): Make static. (ACTIVE_MARK_P): New macro. (skip_block_comment, skip_line_comment): Do not bump the line if ACTIVE_MARK_P is true. (cpp_pop_buffer): The buffer to be popped may not have an active mark. (cpp_get_token): When looking for the initial paren before macro arguments, only set a mark in a file buffer, Always return to that mark before proceeding to call macroexpand or return a NAME token. * cpplib.h: Remove prototypes of parse_set_mark, parse_clear_mark, parse_goto_mark. (struct cpp_options): Rename 'put_out_comments' to 'discard_comments' and invert its sense. * cppinit.c, cpphash.c, cpplib.c: All users of put_out_comments changed to use discard_comments, with opposite sense. From-SVN: r31879
2000-02-09cpplib.c (cpp_define, cpp_undef): Make sure the stacked buffer ends with a ↵Zack Weinberg1-13/+30
newline and a NUL. * cpplib.c (cpp_define, cpp_undef): Make sure the stacked buffer ends with a newline and a NUL. Don't be so clever manipulating strings. From-SVN: r31864
2000-02-07cpplib.c (cpp_get_token): Call CPP_BUMP_LINE after reading a carriage return ↵Mark Mitchell1-0/+1
after a macro name. * cpplib.c (cpp_get_token): Call CPP_BUMP_LINE after reading a carriage return after a macro name. From-SVN: r31840
2000-02-06cpplib.c (my_strerror, [...]): Move to cpperror.c.Zack Weinberg1-367/+18
* cpplib.c (my_strerror, cpp_error, cpp_error_with_line, cpp_error_from_errno, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line, cpp_pedwarn_with_file_and_line): Move to cpperror.c. (cpp_print_file_and_line, v_cpp_error, v_cpp_warning, v_cpp_error_with_line, v_cpp_warning_with_line, cpp_message_from_errno, cpp_perror_with_name): Delete. * cpperror.c (cpp_print_containing_files): Take starting buffer as argument. (cpp_file_line_for_message): Rename to cpp_print_file_and_line. (v_cpp_message): Now called directly by all entry points. Remove -1 case. (cpp_pfatal_with_name, cpp_message): Delete. (cpp_notice_from_errno, cpp_ice): New functions. (cpp_notice): Is now for reporting error conditions, just without an associated file. (cpp_error, cpp_error_with_line): Don't do anything if opts->inhibit_errors is on. (cpp_pedwarn_with_file_and_line): Take column argument also. * cpplib.h: Update prototypes of exported functions. (struct cpp_options): Add inhibit_errors. * cppalloc.c, cppfiles.c: Use fprintf not cpp_notice for non-error messages. Include intl.h. * cppinit.c, cppmain.c: Likewise. Also, use cpp_notice_from_errno instead of cpp_perror_with_name or cpp_pfatal_with_name, and cpp_notice instead of cpp_message. * cppexp.c, cpphash.c, cppinit.c, cpplib.c: Use cpp_ice to report internal errors. * cpplib.c (do_define): Switch bcopy to memcpy. Give cpp_pedwarn_with_file_and_line a dummy column argument. From-SVN: r31829
2000-02-06cpplib.c (copy_rest_of_line): Revert previous change: don't bail out early ↵Zack Weinberg1-2/+0
if we hit a line comment. * cpplib.c (copy_rest_of_line): Revert previous change: don't bail out early if we hit a line comment. From-SVN: r31828
2000-02-06cppfiles.c (read_and_prescan): Bump input pointer before possibly branching ↵Zack Weinberg1-32/+48
off to the backslash code. * cppfiles.c (read_and_prescan) [case SPECCASE_QUESTION]: Bump input pointer before possibly branching off to the backslash code. * cpphash.c (macroexpand): Correctly delete \r escapes when stringifying parameters. * cpplib.c (copy_rest_of_line): Go directly to skip_block_comment if we can; bail out early if we hit a line comment. (handle_directive): Treat '# 123' in an .S file just like '# <punctuation>'. Discard the shifted '#' if we hit '#\n'. Return 1 for '# not_a_directive'. (get_directive_token): Pop macro buffers here, so that cpp_get_token can't sneakily move past a newline. Add sanity checks. (cpp_get_token): goto randomchar if handle_directive returns 0. From-SVN: r31819
2000-02-06cppalloc.c: Update copyright.Zack Weinberg1-35/+39
* cppalloc.c: Update copyright. * cpplib.c: Merge all the static function prototypes into one block. * cpplib.h: Remove #if 0 block. From-SVN: r31818
2000-02-06cpperror.c: Remove #ifdef EMACS block.Zack Weinberg1-122/+48
* cpperror.c: Remove #ifdef EMACS block. * cppmain.c: Likewise. * cpphash.c: Remove #if 0 blocks. * cppinit.c: Remove #if 0 blocks, and the -lint option. * cpplib.c: Remove #if 0 blocks and code referencing pcp_inside_if or for_lint. Remove duplicate error message. Fix error messages for #else after #else or #elif. Reformat. Remove archaic TODO list. * cpplib.h: Remove pcp_inside_if and for_lint flags. From-SVN: r31817
2000-02-06Makefile.in (c-common.o): Depend on $(EXPR_H).Kaveh R. Ghazi1-0/+2
* Makefile.in (c-common.o): Depend on $(EXPR_H). * c-common.c: Include expr.h. * c-pragma.c (mark_align_stack): Add prototype. * caller-save.c (add_stored_regs): Likewise. * combine.c (record_promoted_value): Likewise. * i386.c (ix86_sched_reorder_pentium, ix86_sched_reorder_ppro): Likewise. * cppinit.c (new_pending_define): Likewise. * cpplib.c (skip_block_comment, skip_line_comment): Likewise. * dwarf2out.c (save_rtx, splice_child_die, reverse_die_lists, AT_class, AT_flag, AT_int, AT_unsigned, AT_string, AT_ref, AT_loc, AT_addr, AT_lbl, get_AT_ref, free_AT, free_die, local_scope_p, class_scope_p): Likewise. * dwarf2out.h (dwarf2out_set_demangle_name_func, dwarf2out_add_library_unit_info): Likewise. * ggc.h (ggc_page_print_statistics): Likewise. * haifa-sched.c (propagate_deps): Likewise. * reg-stack.c (next_flags_user, record_label_references): Likewise. * rtl.h (set_stack_check_libfunc): Likewise. * toplev.h (set_fatal_function): Likewise. * toplev.c (set_fatal_function): Delete prototype. * diagnostic.c: Deconstify functions returning malloc'ed ptrs. From-SVN: r31810
2000-02-02cpplib.h (cpp_reader): Add new flag, no_directives.Zack Weinberg1-1/+9
* cpplib.h (cpp_reader): Add new flag, no_directives. * cpphash.c (macarg): Set it. * cpplib.c (handle_directive): If no_directives is on and we find a directive, issue an error and discard the line. From-SVN: r31763
2000-01-30cpperror.c (cpp_file_line_for_message): If 'line' is zero, just print ↵Zack Weinberg1-3/+2
"<command line>". * cpperror.c (cpp_file_line_for_message): If 'line' is zero, just print "<command line>". If 'filename' is null or an empty string, print "<stdin>" for the filename. * cpplib.c (do_define): Don't print the 'location of the previous definition' message if we're still parsing the command line. (cpp_pedwarn_with_file_and_line): Always call cpp_file_line_for_message. From-SVN: r31697
2000-01-27cppinit.c (cpp_handle_option): Recognize C++ comments under -std=gnu89.Zack Weinberg1-130/+114
* cppinit.c (cpp_handle_option): Recognize C++ comments under -std=gnu89. * cpplib.c (skip_block_comment, skip_line_comment): Split code out of... (skip_comment) ... here. Permit C++ comments in system headers always. Warn about C++ comments in user code under -std=gnu89 -pedantic. (copy_comment): Use skip_comment. (cpp_skip_hspace, cpp_get_token): skip_comment can no longer return EOF. (consider_directive_while_skipping, do_else, do_endif): Call validate_else unconditionally. (validate_else): Check CPP_PEDANTIC here. Accept non-comment text after the conditional in a system header. * cpplib.h (struct cpp_buffer): Add flag warned_cplusplus_comments. From-SVN: r31654
2000-01-19more copyright nitsKaveh Ghazi1-1/+1
From-SVN: r31527
2000-01-19cppalloc.c: PROTO -> PARAMS.Kaveh R. Ghazi1-12/+12
* cppalloc.c: PROTO -> PARAMS. * cpperror.c: Likewise. * cppfiles.c: Likewise. * cpplib.c: Likewise. * cpplib.h: Likewise. From-SVN: r31521
2000-01-12cpplib.h (struct cpp_options): Change lang_asm to char.Zack Weinberg1-9/+33
2000-01-11 16:24 -0800 Zack Weinberg <zack@wolery.cumb.org> * cpplib.h (struct cpp_options): Change lang_asm to char. Add lang_fortran. * cppinit.c (builtin_array): Take out __STDC_VERSION__, it's done in cpp_handle_option now. (initialize_builtins): Take out special case code used only by __STDC_VERSION__. (cpp_handle_option): Turn off trigraphs and trigraph warnings if -traditional. Recognize -lang-fortran and set lang_fortran, also turn off cplusplus_comments. (print_help): Document -lang-fortran. * cpplib.c (handle_directive): Ignore `# 123 "file"' if lang_asm. Ignore all directives other than `# 123 "file"' if CPP_PREPROCESSED. (cpp_get_token): If -traditional, don't recognize directives unless the # is in column 1. (parse_string): If lang_fortran or lang_asm, silently terminate strings ('' or "") at end of line. Remove unnecessary braces. From-SVN: r31342
1999-10-29cpplib.h (struct cpp_buffer: fname, [...]): Mark const.Zack Weinberg1-30/+22
1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. From-SVN: r30252
1999-10-03cpplib.c (if_directive_nameo): Add static prototype.Kaveh R. Ghazi1-0/+2
* cpplib.c (if_directive_nameo): Add static prototype. * cse.c (cse_insn): Remove unused variable `p'. * except.c (create_rethrow_ref, push_entry, receive_exception_label, new_eh_region_entry, find_func_region, clear_function_eh_region, process_nestinfo): Add static prototypes. (get_reg_for_handler): Hide definition. (process_nestinfo): Initialize variable `extra_handlers'. * expr.h (expand_builtin_longjmp): Add extern prototype. * final.c (final_addr_vec_align, align_fuzz): Add static prototypes. * function.c (prepare_function_start): Likewise. (pop_function_context_from): Mark parameter `context' with ATTRIBUTE_UNUSED. (push_temp_slots_for_block, flush_addressof): Hide definition. * gcov.c (init_arc, reverse_arcs, create_program_flow_graph, solve_program_flow_graph, calculate_branch_probs, function_summary, main, fancy_abort): Add prototypes. * gen-protos.c (add_hash, parse_fn_proto, main): Likewise. (add_hash): Constify a char*. * ggc-common.c (ggc_mark_rtx_ptr, ggc_mark_tree_ptr, ggc_mark_tree_varray_ptr, ggc_mark_tree_hash_table_ptr, ggc_mark_string_ptr, ggc_mark_tree_hash_table_entry): Add prototypes. * integrate.c (expand_inline_function_eh_labelmap): Likewise. * lists.c (free_list, zap_lists): Likewise. From-SVN: r29783
1999-09-23cpplib.c (handle_directive): Don't complain about `# NUMBER' if we're seeing ↵Jason Merrill1-2/+6
this input for a second time. * cpplib.c (handle_directive): Don't complain about `# NUMBER' if we're seeing this input for a second time. From-SVN: r29634
1999-09-11cppalloc.c (xstrdup): Use memcpy.Zack Weinberg1-22/+51
1999-09-10 22:37 -0700 Zack Weinberg <zack@bitmover.com> * cppalloc.c (xstrdup): Use memcpy. * cpperror.c (cpp_print_containing_files): Don't use cpp_notice. * cpplib.c (conditional_skip): Set temp->lineno. (do_endif): Make error message less obscure. (if_directive_name): New function. (cpp_get_token [case EOF]): Unwind the if stack and generate error messages for each unterminated conditional in this file. (parse_string): Do not behave differently if -traditional. From-SVN: r29279
1999-09-09Makefile.in (cppexp.o): Depend on cpphash.h.Geoff Keating1-13/+99
* Makefile.in (cppexp.o): Depend on cpphash.h. * cppexp.c (cpp_lex): Handle `defined (xxx)' for poisoned xxx. Include cpphash.h. * cpphash.c (special_symbol): Handle plain `xxx' for poisoned xxx. * cpplib.c (do_define): Generalise to handle poisoned definitions, redefining poisoned identifiers, etc. (do_undef): Don't allow poisoned identifiers to be undefined. (do_pragma): Add #pragma poison. (do_xifdef): Handle `#ifdef xxx' for poisoned xxx. * cccp.c: Add T_POISON node type. (special_symbol): Handle `defined(xxx)' and plain `xxx' for poisoned xxx. (do_define): Generalise to handle poisoned definitions, redefining poisoned identifiers, etc. (do_undef): Don't allow poisoned identifiers to be undefined. (do_pragma): Add #pragma poison. (do_xifdef): Handle `#ifdef xxx' for poisoned xxx. * c-pragma.c (handle_pragma_token): Ignore #pragma poison. * c-pragma.h: Add ps_poison state. We now always have generic pragmas. From-SVN: r29224
1999-09-08* cpplib.c (cpp_push_buffer): Fix order of arguments.Jeffrey A Law1-1/+1
From-SVN: r29201
1999-09-07cpperror.c (cpp_file_line_for_message): Constify a char*.Kaveh R. Ghazi1-12/+30
* cpperror.c (cpp_file_line_for_message): Constify a char*. * cppexp.c (parse_number, parse_charconst, cpp_lex, cpp_parse_expr): Add static prototypes. (parse_charconst): Don't cast away const-ness. (token): Constify a char*. * cppfiles.c (file_name_list, include_hash, find_include_file, finclude, initialize_input_buffer): Constify a char*. (file_cleanup, find_position): Add static prototypes. * cpphash.c (macro_cleanup, macarg, timestamp, special_symbol, collect_expansion): Add static prototypes. (cpp_install, create_definition, monthnames): Constify a char*. * cpphash.h (cpp_install): Likewise. * cppinit.c (known_suffixes, default_include, dump_special_to_buffer, NAME, cpp_start_read, cpp_finish): Likewise. (base_name, dump_special_to_buffer, initialize_dependency_output): Add static prototypes. * cpplib.c (my_strerror): Constify a char*. (null_underflow, null_cleanup, skip_comment, copy_comment, copy_rest_of_line, handle_directive, pass_thru_directive, get_directive_token, read_line_number, cpp_print_file_and_line, v_cpp_error, v_cpp_warning, v_cpp_error_with_line, v_cpp_warning_with_line, detect_if_not_defined, consider_directive_while_skipping): Add static prototypes. (pass_thru_directive, check_macro_name, cpp_expand_to_buffer, cpp_pedwarn_with_file_and_line): Constify a char*. * cpplib.h (cpp_options, include_hash, progname, definition, cpp_pedwarn_with_file_and_line, cpp_expand_to_buffer, check_macro_name, cpp_pfatal_with_name, cpp_file_line_for_message, find_include_file, deps_output, include_hash): Constify a char*. * cppmain.c (progname): Constify. (main): Add prototype. Use return, not exit. * fix-header.c (fatal, add_symbols, lookup_std_proto, write_lbrac, recognized_macro, check_macro_names, read_scan_file, write_rbrac, inf_skip_spaces, inf_read_upto, inf_scan_ident, inf_scan_ident, check_protection): Add static prototype. (xfree): Remove. (progname, recognized_macrom, recognized_extern): Constify a char*. (main): Add prototype. * gen-protos.c (progname): Constify a char*. From-SVN: r29171
1999-08-31cpplib.c (struct directive): Const-ify name pointer and function pointer ↵Zack Weinberg1-66/+69
prototype. 1999-08-31 12:44 -0700 Zack Weinberg <zack@bitmover.com> * cpplib.c (struct directive): Const-ify name pointer and function pointer prototype. (validate_else, do_define, do_line, do_include, do_undef, do_error, do_pragma, do_ident, do_if, do_xifdef, do_else, do_elif, do_endif, do_sccs, do_assert, do_unassert, do_warning): Const-ify second arg. (directive_table): Mark const. Reorder entries by frequency of usage, record statistics. From-SVN: r29009
1999-08-25cpplib.c (detect_if_not_defined): New function.Jim Meyering1-1/+77
1999-08-25 13:51 -0700 Jim Meyering <meyering@ascend.com> * cpplib.c (detect_if_not_defined): New function. (do_if): Use it to detect potential once-only headers. From-SVN: r28877
1999-08-13cpplib.c (read_line_number): New fn, split out of...Jason Merrill1-25/+44
* cpplib.c (read_line_number): New fn, split out of... (do_line): Here. From-SVN: r28707
1999-08-04Warning fixes:Kaveh R. Ghazi1-1/+0
* builtins.c (expand_builtin_memcmp, expand_builtin_strcmp): Wrap prototypes in macro HAVE_cmpstrsi. * cpplib.c (cpp_get_token): Remove unused label `op3'. * emit-rtl.c (operand_subword): Remove unused variable `bits_per_word'. * rtl.c (shallow_copy_rtx): Remove unused variable `format_ptr'. * tree.c (chainon): Wrap variable `t2' in macro ENABLE_CHECKING. From-SVN: r28514
1999-08-04cpphash.c (macroexpand): Delete leading whitespace when arg is concatenated ↵Zack Weinberg1-16/+38
before. Wed Aug 4 13:29:23 1999 Zack Weinberg <zack@bitmover.com> * cpphash.c (macroexpand): Delete leading whitespace when arg is concatenated before. (unsafe_chars): Correct test for whether + and - can extend a token. * cppinit.c (cpp_start_read): Do dependencies for -include/-imacros files also. * cpplib.c (cpp_scan_buffer): In no-output mode, don't bother tokenizing non-directive lines. (cpp_expand_to_buffer): Temporarily disable no-output mode. * cppmain.c: In no-output mode, just call cpp_scan_buffer for the input file. From-SVN: r28512
1999-07-26cpplib.c (cpp_get_token): Don't return a CPP_POP if the buffer has ↵Jason Merrill1-5/+6
manual_pop set. * cpplib.c (cpp_get_token): Don't return a CPP_POP if the buffer has manual_pop set. From-SVN: r28275
1999-07-20gcc.c (default_compilers, cpp-output): Pass -fpreprocessed.Jason Merrill1-4/+30
* gcc.c (default_compilers, cpp-output): Pass -fpreprocessed. * toplev.c (documented_lang_options): Add -fpreprocessed. * cpplib.h (struct cpp_buffer): Add preprocessed. * cppinit.c (cpp_handle_option): Handle -fpreprocessed. (cpp_start_read): Don't expand macros or emit an initial #line directive if -fpreprocessed. * cpplib.h (struct cpp_buffer): Added manual_pop for better C++ tokenization. * cpplib.c (cpp_get_token): Return CPP_EOF if manual_pop. Also, support C++ tokenization for ->*, .*, <?, and >? operators. * c-common.c (cpp_token): Make non-static. From-SVN: r28190
1999-06-07cpplib.c (do_define): Cast `alloca' return value.Dave Brolley1-4/+4
Mon Jun 7 13:33:39 1999 Dave Brolley <brolley@cygnus.com> * cpplib.c (do_define): Cast `alloca' return value. (do_include, do_undef, do_pragma): Likewise. * cpphash.c (dump_definition): Cast `xstrdup' and `alloca' return values. * cppfiles.c (initialize_input_buffer): Cast `xmalloc' return values. * gcc/cppspec.c (lang_specific_driver): Cast xmalloc return value. From-SVN: r27391
1999-04-26cpphash.c (dump_definition): New function.Zack Weinberg1-146/+92
1999-04-26 19:16 -0400 Zack Weinberg <zack@rabi.columbia.edu> * cpphash.c (dump_definition): New function. * cpphash.h: Prototype it. * cpplib.c (handle_directive): Don't output anything here. Streamline. (pass_thru_directive): Take a length, not a pointer to the end. All callers changed. (do_define): Handle -dD, -dN, -g3 entirely here. Streamline. (do_include): Handle -dI here. (do_ident): Correct to match cccp. (do_pragma): Copy the pragma through here. (do_assert, do_unassert): Tidy. * cppinit.c (cpp_finish): If -dM was specified, walk the macro hash table and call dump_definition on all the entries. * cppmain.c: cpp_finish may produce output. From-SVN: r26659
1999-04-19cpplib.c (output_line_command): Drop CONDITIONAL argument.Zack Weinberg1-20/+25
1999-04-19 14:51 -0400 Zack Weinberg <zack@rabi.columbia.edu> * cpplib.c (output_line_command): Drop CONDITIONAL argument. We can omit unnecessary line commands if file_change == same_file and pfile->lineno != 0. All callers changed. (cpp_get_token [case '\n']): Don't bump pfile->lineno if CPP_OPTIONS (pfile)->no_line_commands is set. * cpplib.h: Fix prototype of output_line_command. From-SVN: r26547
1999-04-14cpperror.c, [...]: Never call abort.Zack Weinberg1-1/+4
1999-04-14 12:37 -0400 Zack Weinberg <zack@rabi.columbia.edu> * cpperror.c, cppexp.c, cpplib.c: Never call abort. * cpphash.c: Only call abort when we detect corruption of the malloc arena. * cppmain.c: Don't define fatal or fancy_abort. From-SVN: r26442
1999-04-12cpphash.c (collect_expansion, [...]): Make the escape character in macro ↵Zack Weinberg1-56/+85
buffers '\r', not '@'. 1999-04-12 14:55 -0400 Zack Weinberg <zack@rabi.columbia.edu> * cpphash.c (collect_expansion, macroexpand, push_macro_expansion): Make the escape character in macro buffers '\r', not '@'. Remove code to protect literal occurences of the escape character; '\r' cannot appear in a macro buffer unless we put it there. * cpplib.c (skip_comment, copy_comment, cpp_skip_hspace, copy_rest_of_line, cpp_get_token, parse_string, parse_assertion): '\r' might be a backslash-newline marker, or it might be a macro escape marker, depending on CPP_BUFFER (pfile)->has_escapes. '@' is not a special character. * cpplib.h: Update commentary. From-SVN: r26371
1999-03-19Warning fixes:Kaveh R. Ghazi1-12/+12
* cccp.c (create_definition): Cast to U_CHAR* when assigning to one. * cppfiles.c (read_and_prescan): Likewise. Start a #define in column 0. * cpplib.c (cpp_define): Cast to U_CHAR* when assigning to one. (cpp_push_buffer): Likewise for cpp_buffer*. (do_include): Change the type of `fbeg' and `fend' to unsigned char*. (do_endif): Cast to char* when assigning to one. (do_assert): Likewise. (do_unassert): Likewise. (cpp_read_check_assertion): Change the type of `name' to U_CHAR*. Don't do unnecessary cast to char* anymore. * genrecog.c (make_insn_sequence): Cast to char** when assigning to one. Cast the first argument of bzero to PTR. * loop.c (strength_reduce): Remove unused variable `note'. * reload1.c (new_insn_chain): Cast to struct insn_chain* when assigning to one. * rtl.c (copy_rtx): Use memcpy instead of bcopy. From-SVN: r25860
1999-03-16cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot ↵Zack Weinberg1-450/+370
otherwise appear in the processed... 1999-03-16 16:06 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppfiles.c (read_and_prescan): Map backslash-newline to '\r' (which cannot otherwise appear in the processed buffer) and move it out of tokens that it appears in the middle of. Improve performance. (find_position): New function. * cpplib.c: \r (one character) indicates backslash newline, not \\\n (two characters). It cannot appear in the middle of a token. Call CPP_BUMP_LINE (pfile) whenever parsing moves past \n or \r. Increment pfile->lineno whenever a \n is placed into token_buffer. Only one mark can exist at a time, and CPP_BUMP_LINE must not be used while it is active. It is automatically cleared by cpp_pop_buffer and parse_goto_mark. \r is not in is_hor_space or is_space. (NEWLINE_FIX, NEWLINE_FIX1, adjust_position, update_position, count_newlines, parse_move_mark): Removed. (parse_string, copy_comment): New functions. (parse_name): Returns void. (parse_set_mark, parse_clear_mark, parse_goto_mark): Take only one argument, a cpp_reader *. Change for new marking scheme. (skip_comment): Handle CHILL line comments too. Second argument is now first character of comment marker; all callers changed. Issue error for unterminated block comment here. (cpp_skip_hspace): Recognize CHILL comments. (copy_rest_of_line): Likewise. Call skip_comment and parse_string directly, don't go through cpp_get_token. Emit "/**/" for block comments if -traditional (create_definition needs this). (do_define): Don't play with put_out_comments. (cpp_push_buffer): Initialize ->mark to -1. (cpp_buf_line_and_col): Just read out the values in the buffer structure. (output_line_command): Use cpp_buf_line_and_col. Fix formatting. Remove stale code. (cpp_get_token): Break out string parsing code to parse_string. Use skip_comment for CHILL comments too. Use copy_comment for put_out_comments instead of dinking with marks. Remove stale code. Don't call output_line_command unless it's necessary. * cpplib.h (parse_marker): Removed. (struct cpp_buffer): line_base is now a unsigned char *; add `mark' [long], remove `marks' [struct parse_marker *]. (parse_set_mark, parse_clear_mark, parse_goto_mark): Update prototypes. (CPP_BUMP_LINE, CPP_BUMP_BUFFER_LINE): New macros. * cppinit.c (is_hor_space, is_space): '\r' is not considered whitespace. * cppexp.c (cpp_parse_expression): Use cpp_skip_hspace, not SKIP_WHITE_SPACE. * cpphash.c (macarg): Disable line commands while expanding. From-SVN: r25802
1999-03-15cppinit.c: Instead of one pending list...Zack Weinberg1-0/+13
1999-03-15 21:39 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cppinit.c: Instead of one pending list, keep separate lists for each category of pending option: -D/-U, -A, -include, -imacros. Move the four partial include-path lists into the pending block. Use head and tail pointers so we don't ever have to reverse the lists. (cpp_start_read): Break out blocks of code to their own functions: install_predefs and initialize_dependency_output. Use path_include for C_INCLUDE_PATH and friends as well as CPATH. Remove include_defaults gunk. Warn about the combination of -lang-chill and -trigraphs. Optimize string bashing. Walk each pending list once, deallocating as we go. (append_include_chain): Brought over from cppfiles.c. Mark dirs as system include dirs if and only if appending to system include path. If opts->verbose, print a notice when a dir is dropped from the include path because it doesn't exist. Fix memory leak: this function is not supposed to copy its DIR argument. (nreverse_pending, push_pending): Removed. (APPEND): New macro for adding to pending lists. (path_include): Can now add to any partial include path. (base_name): Bring over from cccp.c. (cpp_options_init): Allocate the pending block. (cpp_handle_option): Add --version. Exit after --help. Fix formatting. Order -ifoo options by frequency of usage. (install_predefs): New function, simplified version of code that was in cpp_start_read. (initialize_dependency_output): Likewise. Understand OBJECT_SUFFIX. * cppfiles.c (simplify_pathname): Export. (merge_include_chains): Don't nreverse the lists. If opts->verbose, print a notice when a duplicate dir is detected and dropped from the include path. (finclude): Fix excessive cleverness in setting fp->system_header_p. (actual_directory): Set x->sysp from CPP_BUFFER (pfile)->system_header_p so that one system header may include another with "". (deps_output): Fix double adjustment of deps_size which would cause all dependencies after the first two lines to be lost. * cpplib.c (cpp_unassert): New function. * cpplib.h: Lay out struct cpp_pending here. Adjust prototypes. Add include_prefix_len to struct cpp_options. From-SVN: r25793
1999-02-25Makefile.in (cppmain.o, [...]): Don't depend on machmode.h.Kaveh R. Ghazi1-6/+6
* Makefile.in (cppmain.o, cpplib.o, cpphash.o, cppalloc.o, cpperror.o, cppexp.o, cppfiles.o, cppinit.o, fix-header.o, scan-decls.o): Don't depend on machmode.h. * cppexp.c: Don't define CHAR_BIT or HOST_BITS_PER_WIDE_INT anymore. Replace all instances of HOST_WIDE_INT with HOST_WIDEST_INT. * cppfiles.c: Likewise. * cpplib.c: Likewise. * cpplib.h: Likewise. Also don't include machmode.h anymore. From-SVN: r25446
1999-02-25cpphash.c (install): Rename to cpp_install, add cpp_reader* first argument.Zack Weinberg1-5/+5
1999-02-25 17:14 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cpphash.c (install): Rename to cpp_install, add cpp_reader* first argument. All callers changed. (hashtab): Removed. (cpp_lookup, cpp_install): Change all refs to hashtab to pfile->hashtab. (cpp_hash_cleanup): Removed. * cpphash.h: Adjust prototypes. * cpplib.h (struct cpp_reader): Add hashtab pointer. * cppinit.c (cpp_reader_init): Also allocate space for the hashtab. (cpp_cleanup): Delete all macros and free the hashtab. From-SVN: r25441
1999-02-18cpplib.c: Kill define of STDC_VALUE.Zack Weinberg1-2922/+14
1999-02-18 18:32 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cpplib.c: Kill define of STDC_VALUE. Don't include output.h or prefix.h. Change CPP_IS_MACRO_BUFFER to not refer to macro_cleanup. (GET_ENV_PATH_LIST, PATH_SEPARATOR, STANDARD_INCLUDE_DIR, predefs, SIZE_TYPE, PTRDIFF_TYPE, WCHAR_TYPE, CPP_WCHAR_TYPE, USER_LABEL_PREFIX, REGISTER_PREFIX, struct cpp_pending, version_string, struct default_include, include_defaults_array, path_include, cpp_options_init, dump_special_to_buffer, initialize_builtins, cpp_start_read, cpp_reader_init, nreverse_pending, push_pending, print_help, cpp_handle_option, cpp_handle_options, cpp_finish, cpp_cleanup): Move to cppinit.c. (macro_cleanup, struct arglist, collect_expansion, create_definition, compare_defs, comp_def_part, ARG_BASE, struct argdata, macarg, change_newlines, timestamp, monthnames, special_symbol, unsafe_chars, macroexpand, push_macro_expansion): Move to cpphash.c. (quote_string, check_macro_name, cpp_expand_to_buffer, output_line_command, cpp_undef): Export. (null_underflow, null_cleanup, handle_directive): Make static. * cpplib.h: Prototype now-exported functions. Adjust decls of syntax tables so we can include cpplib.h in cppinit.c. * cpphash.h: Prototype all functions exported by cpphash.c. * cppinit.c: Make syntax tables initialized data if possible (uses GCC designated-initializer extension). * cppexp.c: Make cpp_lex static. * Makefile.in: Move -D switches for the various include dirs from cpplib.o rule to cppinit.o rule. Adjust dependencies. From-SVN: r25287
1999-02-15c-common.c (UNGETC [USE_CPPLIB=1]): Do nothing if c is EOF.Zack Weinberg1-21/+36
1999-02-15 16:59 -0500 Zack Weinberg <zack@midnite.ec.rhno.columbia.edu> * c-common.c (UNGETC [USE_CPPLIB=1]): Do nothing if c is EOF. * c-lex.c: Likewise. * cpplib.c (cpp_push_buffer, cpp_pop_buffer): Use a linked list in malloced memory for the buffer stack. (cpp_get_token): Don't pop the last buffer off the stack. Calls after CPP_EOF has been returned produce CPP_EOF with no state change. (cpp_finish): Pop last buffer here. (do_line): Don't free ip->last_nominal_fname if it is equal to ip->fname. (special_symbol): If a T_CONST is the empty string, push a single `@ ' escape instead. (macroexpand): Special symbol buffers have escapes too. * cpplib.h (struct cpp_buffer): Remove unused fields, add prev buffer pointer. (struct cpp_reader): Remove buffer_stack. Add buffer_stack_depth. (CPP_PREV_BUFFER, CPP_NULL_BUFFER): Buffer stack is now a linked list. From-SVN: r25218
1999-02-09cpplib.c (special_symbol): Move IP to be declared in function scope, rather ↵Brendan Kehoe1-2/+3
than individual case statements. * cpplib.c (special_symbol): Move IP to be declared in function scope, rather than individual case statements. fixes building under solaris From-SVN: r25112
1999-02-09cpplib.c (do_define): Allow redefining __STDC__ with -D.Zack Weinberg1-1/+1
1999-02-09 10:30 -0500 Zack Weinberg <zack@rabi.columbia.edu> * cpplib.c (do_define): Allow redefining __STDC__ with -D. From-SVN: r25109
1999-02-08cpplib.c (special_symbol): Rewrite.Zack Weinberg1-184/+103
1999-02-08 23:25 -0500 Zack Weinberg <zack@midnite.ec.rhno.columbia.edu> * cpplib.c (special_symbol): Rewrite. Don't copy things multiple times. Handle __STDC__ specially. T_CONST indicates a constant /string/. Don't handle T_*_TYPE and T_SPEC_DEFINED. Use cpp_buf_line_and_col instead of adjust_position. Determine the file buffer only if needed. (initialize_builtins): Handle __SIZE_TYPE__, __PTRDIFF_TYPE__, __WCHAR_TYPE__, __USER_LABEL_PREFIX__, and __REGISTER_PREFIX__ with T_CONST special hashtab entries. Don't provide __OBJC__; the driver does that. Provide __STDC_VERSION__, using T_CONST. Use T_STDC for __STDC__. Give install the length of all symbols defined. (eval_if_expression): Drop code to insert and remove the "defined" special symbol. * cpplib.h: Remove SELF_DIR_DUMMY (no longer used). Remove T_*_TYPE and T_SPEC_DEFINED from enum node_type; add T_STDC. * cpphash.c (install): Drop the `ivalue' parameter. Constify the `value' parameter. All callers changed. * cpphash.h (install): Change prototype to match. (union hashval): Remove `ival' member. * cppexp.c (cpp_lex): Handle `defined' here. From-SVN: r25097
1999-02-04cpplib.c (initialize_char_syntax): Move to cppinit.c.Zack Weinberg1-370/+150
1999-02-04 14:33 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c (initialize_char_syntax): Move to cppinit.c. (cpp_define): Remove redundant syntax checks. (make_assertion): Rename cpp_assert, remove redundant syntax checks, export. (cpp_options_init): Don't init things to zero twice. (cpp_expand_to_buffer): Use memcpy, not a char-by-char loop. (do_include): Kill excessively verbose import warning that snuck back in in the gcc2 merge. (convert_string): Removed. (do_line): Rewrite with simple last-name-used cache instead of private hashtable. (cpp_start_read): Call initialize_char_syntax here, not... (cpp_reader_init): ...here. (cpp_handle_options): Support the -std switch. * cpplib.h (cpp_buffer): Add last_nominal_fname member. (cpp_options): Add c9x flag. Declare all the is_* tables and trigraph table here, as const. Prototype cpp_assert and initialize_char_syntax. * cppinit.c: New file. * cppfiles.c (read_and_prescan): Optimize. * Makefile.in (LIBCPP_OBJS): Add cppinit.o. From-SVN: r25024
1999-01-29collect2.c (error): Fix typo in declaration.Kaveh R. Ghazi1-1/+1
* collect2.c (error): Fix typo in declaration. * cpperror.c (cpp_message): Likewise. * cpplib.c (cpp_warning): Likewise. * cpplib.h (cpp_notice): Use PVPROTO not VPROTO, also add ATTRIBUTE_PRINTF_1. * toplev.c (error): Fix typo in declaration. From-SVN: r24904
1999-01-26Merge in gcc2 snapshot 19980929. See gcc/ChangeLog and gcc/FSFChangeLog forJeffrey A Law1-74/+88
details. From-SVN: r24879