Commit Graph

110 Commits

Author SHA1 Message Date
Zack Weinberg
711b88243b [multiple changes]
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-18 00:59:49 +00:00
Zack Weinberg
2c0accc920 cpphash.c (save_expansion): Clear PREV_WHITE on tokens immediately following 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-15 19:29:14 +00:00
Neil Booth
b30892f96d cpphash.c (struct macro_info): Add new members.
* cpphash.c (struct macro_info): Add new members.
	(_cpp_free_definition): Delete the macro directly.
	(count_params): Return void, with first token of
	expansion in struct macro_info on success.
	(parse_define): Return int.  Hoist syntax checking from
	save_macro_expansion.  Leave call to save_expansion to
	_cpp_create_definition.
	(alloc_macro): Needs just 2 arguments.
	(free_macro): Delete.
	(save_expansion): Don't perform syntax check.
	(_cpp_create_definition): Call save_expansion.

From-SVN: r35025
2000-07-13 21:49:33 +00:00
Kaveh R. Ghazi
af0d1578e4 * cpphash.c (macro_info): Don't use the `signed' keyword.
From-SVN: r35023
2000-07-13 20:09:55 +00:00
Zack Weinberg
f9a0e96c17 cppexp.c, [...]: Eradicate all traces of code dependent on traditional, lang_chill, or lang_fortran.
* cppexp.c, cpphash.c, cpphash.h, cppinit.c, cpplex.c,
	cpplib.c, cpplib.h: Eradicate all traces of code dependent on
	traditional, lang_chill, or lang_fortran.

	* cppfiles.c: #undef strcmp to suppress warning about macros
	used without arguments.
	(_cpp_execute_include): Use f, not fname, in "No include path"
	error.
	(_cpp_pop_file_buffer): New function.
	* cpplib.c: Don't include <sys/mman.h>.
	(cpp_push_buffer): Set line_base and lineno in new buffer.
	(cpp_pop_buffer): Use _cpp_pop_file_buffer.

	* cpplex.c: Move all prototypes and structure declarations to the
	top of the file.  Properly parenthesise some macro arguments.
	(cpp_scan_line): New function.
	(special_symbol [case T_INCLUDE_DEPTH]): Use pfile->include_depth,
	don't need to walk up the stack counting.

From-SVN: r35003
2000-07-13 02:32:41 +00:00
Zack Weinberg
0080e89292 cppexp.c (LOGICAL): Delete macro.
* cppexp.c (LOGICAL): Delete macro.
	(_cpp_parse_expr): Do not use UNARY for unary +.  Implement ||
	and && directly.

	* cpphash.c (HASHSIZE): Increase to 4096.
	(struct hashdummy): Add hash field.
	(eq_HASHNODE): Compare unreduced hashes, then lengths, then
	the string values using memcmp.
	(cpp_lookup): Set dummy.hash.

From-SVN: r34994
2000-07-12 19:41:30 +00:00
Neil Booth
2964d54fa6 cpphash.h: (TOKEN_SPELL) Pulled from cpplex.c.
* cpphash.h: (TOKEN_SPELL) Pulled from cpplex.c.
	* cpplex.c (TOKEN_SPELL) Move to cpphash.h.

	* cpphash.c: (struct macro_info, alloc_macro, free_macro,
	struct toklist_dummy): New.
	(cpp_free_definition): Free macros with free_macro.
	(count_params): Don't save paramter spellings.  Save macro
	information in a struct macro_info.
	(parse_define): Don't allocate a token list.
	(save_expansion): Allocate the macro's token list, and
	save parameter spellings if necessary.  Use TOKEN_SPELL.
	(cpp_create_definition): Make list const.

From-SVN: r34985
2000-07-12 14:37:47 +00:00
Zack Weinberg
417f3e3a5e [multiple changes]
2000-07-11  Zack Weinberg  <zack@wolery.cumb.org>

	* cpplex.c (parse_name): No longer inline (premature optimization).
	(do_pop_context): Fold into pop_context.
	(pop_context): Returns int.
	(lex_next): Hoist test for end of directive into pop_context.
	(push_macro_context): Returns int; takes just reader and token.
	Hoist test for excessive nesting to caller.
	(push_arg_context): Returns void; takes just reader and token.
	Do not call stringify_arg or get_raw_token.
	(get_raw_token): Convert tail recursion through	push_arg_context
	to a loop at this level.  Call stringify_arg here if appropriate.
	(maybe_paste_with_next): Convert tail recursion to a while loop.
	Hoist test of paste_level to caller.

	(stringify_arg): Push arg context at beginning.
	(cpp_get_token): Split out core into _cpp_get_token.  Call
	process_directive here.  Throw away CPP_PLACEMARKER tokens.
	(_cpp_get_token): Convert tail recursion through
	push_macro_context to a loop at this level.
	(_cpp_glue_header_name, is_macro_disabled, stringify_arg,
	_cpp_get_raw_token): Use _cpp_get_token.
	(_cpp_skip_rest_of_line): Drop the context stack directly; do
	not call pop_context.
	(_cpp_run_directive): Call lex_next directly.

	* cpphash.h: Prototype _cpp_get_token.
	* cppexp.c (lex): Use it.
	* cpphash.c (parse_define): Use it.
	* cpplib.c (get_define_node, do_undef, parse_include,
	read_line_number, do_line, do_ident, do_pragma, do_pragma_gcc,
	do_pragma_implementation, do_pragma_poison, do_pragma_dependency,
	parse_ifdef, validate_else): Use it.
	(cpp_push_buffer): Tweak error message; abort if anyone tries
	to push a buffer while macro expansions are stacked.

2000-07-11  Donn Terry  <donnte@microsoft.com>

	* cpplex.c (free_macro_args, save_token): Cast arg of free
	and/or xrealloc to PTR.
	(_cpp_init_input_buffer): Clear all fields of the base context.

From-SVN: r34972
2000-07-11 23:20:53 +00:00
Zack Weinberg
bfb9dc7faa cpplib.h (struct cpp_name): Now struct cpp_string.
* cpplib.h (struct cpp_name): Now struct cpp_string.
	(CPP_INT, CPP_FLOAT, CPP_NUMBER, CPP_COMMENT,
	CPP_HEADER_NAME): Change to type S.
	(struct cpp_token): Rename 'name' field to 'str'.  Add 'node'
	field, a cpp_hashnode *.  All references to val.name updated
	to use val.str or val.node as appropriate.
	(struct cpp_reader): Add spec_nodes field.
	(cpp_idcmp): Now cpp_ideq; takes a token * and a char *.

	* cpphash.h (struct spec_nodes): New.
	(enum spell_type): Reorder.  Only SPELL_STRING tokens use
	val.str.  All references to 'spelling > SPELL_NONE' updated to
	match.

	(CPP_IN_SYSTEM_HEADER): Check pfile->buffer and
	pfile->buffer->inc are not NULL before dereferencing them.

	* cpplex.c (parse_name): Take a pointer to the current token,
	plus current position and limit as args; return the new
	position; don't copy the text of a name into the string
	buffer, instead call cpp_lookup and store the node pointer.
	If extending a token, copy out the text of the old into a
	scratch buffer, append the new, look that up and store the new
	node pointer.  Inline.
	(maybe_paste_with_next): If the result of paste is a NAME,
	then look up the pasted text and store its node pointer.
	(lex_line): Adjust for new parse_name interface.
	Check for L"str", L'str' using spec_nodes->n_L.
	(spell_token): SPELL_IDENT tokens have their spelling in
	val.node->name.  Handle SPELL_STRING tokens that don't have
	string delimiters.
	(_cpp_expand_name_space,
	(can_paste): Check for L ## "str" using spec_nodes->n_L.
	(cpp_get_token, special_symbol): No need to call cpp_lookup.
	(cpp_idcmp): Now cpp_ideq; take a token * and a const char *;
	return 1=equal 0=not, not a tristate.

	* cpphash.c (var_args_str): Delete.
	(find_param): Compare node fields directly.
	(is__va_args__): Use CPP_PEDANTIC.  Just compare
	token->val.node with spec_nodes->n__VA_ARGS__.
	(dump_funlike_macro): Don't use var_args_str.

	* cpplib.c (_cpp_check_directive): Just walk through
	spec_nodes->dirs comparing pointers.
	(get_define_node, do_pragma_poison, detect_if_not_defined,
	parse_ifdef): The identifier has already been looked up.
	(do_ifdef, do_ifndef): parse_ifdef won't return a poisoned
	node.
	(do_if): Only call detect_if_not_defined at beginning of file.
	(_cpp_parse_assertion): Only copy string pointers for
	SPELL_STRING tokens.
	(pragma_dispatch): Take a node pointer and examine its name
	field.
	(_cpp_init_stacks): Also initialize the spec_nodes structure.

	* cppinit.c (cpp_reader_init): Call _cpp_init_stacks after
	_cpp_init_macros.
	(cpp_cleanup): Free pfile->spec_nodes.  Call _cpp_cleanup_* in
	reverse order from the corresponding _cpp_init_* routines.

	* cppexp.c (parse_number, parse_charconst, parse_defined,
	lex): Check val.node->type instead of calling cpp_defined.
	Use spec_nodes entries where appropriate.

	* fix-header.c, scan-decls.c: Update for interface changes.

From-SVN: r34926
2000-07-08 19:00:39 +00:00
Neil Booth
563dd08adf cpphash.c (is__va_args__): New function.
* cpphash.c (is__va_args__): New function.
	(count_params): Fix line reported in error messages.  Use
	is__va_args__.  Don't return ')' on error.  Flag GNU style
	rest args macro definitions.
	(parse_define): Check macro name is not __VA_ARGS__.
	(save_expansion): Check identifier in non-varargs-macro is
	not __VA_ARGS__.  Don't flag GNU_VARARGS.
	* cpplex.c (parse_args): Accept no argument iff GNU_REST_ARGS.
	(maybe_paste_with_next): Use per-macro GNU_REST_ARGS rather
	 than per-token GNU_VARARGS.
	* cpplib.h (GNU_VARARGS): Remove.
	(GNU_REST_ARGS): New.

	* gcc.dg/cpp/macsyntx.c: New tests.

From-SVN: r34919
2000-07-08 02:18:25 +00:00
Zack Weinberg
c71f835b25 cpplex.c: Don't include sys/mman.h.
toplevel:
	* cpplex.c: Don't include sys/mman.h.
	(cpp_push_buffer, cpp_pop_buffer): Moved to cpplib.c.

	* cpplib.c: Include sys/mman.h and obstack.h.
	(cpp_push_buffer): Moved from cpplex.c; allocate buffers on an
	obstack.
	(cpp_pop_buffer): Moved from cpplex.c; free buffers from an obstack.
	(_cpp_unwind_if_stack): Now static, unwind_if_stack.  Don't
	bother freeing if stack entries (they will be freed with their buffer).
	(do_endif): Free if stack entries from the buffer obstack.
	(push_conditional): Allocate if stack entries from the buffer obstack.

	(find_answer): Rename to _cpp_find_answer.
	(do_assert, do_unassert): Update.

	* cpphash.h: Update prototypes.
	(xobnew): New convenience macro.
	* cpplib.h (struct cpp_reader): Add hash_ob and buffer_ob fields.
	Update comments.
	(struct cpp_hashnode): Remove disabled field.

	* cppinit.c: Don't include hashtab.h or splay-tree.h.
	(report_missing_guard): Moved to cppfiles.c.
	(cpp_reader_init): Call cpp_init_stacks, cpp_init_macros,
	cpp_init_includes.
	(cpp_cleanup): Call cpp_cleanup_stacks, cpp_cleanup_macros,
	cpp_cleanup_includes.  Don't destroy hashtab or
	all_include_files here.
	(cpp_finish): Use _cpp_report_missing_guards.

	* cppfiles.c (report_missing_guard): Moved from cppinit.c.
	(_cpp_init_include_table): Rename _cpp_init_includes.
	(_cpp_cleanup_includes, _cpp_report_missing_guards): New.

	* cppexp.c (parse_assertion): Update for new name of
	find_answer.

	* Makefile.in (cpplib.o, cpphash.o, cppinit.o): Update deps.

	* cpplib.c (do_ident): s/VSPACE/EOF/

testsuite:
	* gcc.dg/cpp/ident.c: New test.

From-SVN: r34870
2000-07-05 05:33:57 +00:00
Zack Weinberg
041c31944c top level:
2000-07-03  Zack Weinberg  <zack@wolery.cumb.org>

	* fix-header.c (struct partial_proto): Remove unnecessary fields.
	(recognized_extern, recognized_function, read_scan_file):
	Update for new scheme.
	(check_protection): It's still a multiple include guard even
	if it doesn't always trigger.
	* scan-decls.c (skip_to_closing_brace, scan_decls): Update for
	new scheme.
	* scan.h: Declare struct cpp_token.  Update prototypes.

2000-07-03  Neil Booth  <neilb@earthling.net>
	    Zack Weinberg  <zack@wolery.cumb.org>

	Complete overhaul of the lexer and macro expander.

	* cpphash.c (object_defn, funct_defn, push_macro_expansion,
	arg, arglist, argdata, reflist, collect_objlike_expansion,
	collect_funlike_expansion, collect_params,
	warn_trad_stringify, trad_stringify, duplicate_arg_p, add_pat,
	unsafe_chars, macarg, compare_defs, special_symbol,
	scan_arguments, stringify, funlike_macroexpand,
	_cpp_quote_string, monthnames): Delete.
	(cpp_lookup, _cpp_free_definition, dump_funlike_macro,
	_cpp_create_definition, _cpp_dump_definition,
	dump_hash_helper): Adjust.
	(find_param, count_params, parse_define, var_args_str,
	check_macro_redefinition, save_expansion): New.

	* cpplex.c (skip_block_comment, skip_line_comment, parse_name,
        parse_string, output_line_command, trigraph_replace,
        lex_line, cpp_push_buffer, cpp_pop_buffer, cpp_output_tokens,
        cpp_scan_buffer_nooutput, cpp_scan_buffer, cpp_free_toklist,
        cpp_idcmp, _cpp_get_directive_token, _cpp_init_input_buffer,
	_cpp_skip_rest_of_line): Modify.

        (maybe_macroexpand, skip_comment, copy_comment, skip_string,
	find_position, null_warning, bump_column, expand_name_space,
	pedantic_whitespace, _cpp_output_list, _cpp_slice_toklist,
	_cpp_squeeze_toklist, _cpp_scan_until, _cpp_skip_hspace,
	_cpp_parse_name, _cpp_lex_token, cpp_get_non_space_token,
	_cpp_prescan): Delete.

	(dump_param_spelling, process_directive, lex_next,
        is_macro_disabled, stringify_arg, expand_context_stack,
        output_token, make_string_token, alloc_number_token,
        special_symbol, duplicate_token, maybe_paste_with_next,
        can_paste, prevent_macro_expansion, restore_macro_expansion,
        get_temp_token, release_temp_tokens, quote_string,
        token_names, token_spellings, _cpp_expand_name_space,
        _cpp_glue_header_name, _cpp_reserve_name_space,
        digraph_spellings, trigraph_ok, skip_whitespace, save_comment,
        placemarker_token, eof_token, cpp_context, macro_args,
        get_raw_token, parse_arg, parse_args, save_token,
        push_arg_context, push_macro_context, pop_context,
        do_pop_context, free_macro_args, _cpp_get_line,
        _cpp_run_directive): New.

	* cpplib.c (validate_else, parse_include, push_conditional,
	pass_thru_directive, read_line_number, parse_ifdef,
	detect_if_not_defined, _cpp_check_directive, do_define,
	do_undef, do_include, do_import, do_include_next, do_error,
	do_warning, do_ident, do_pragma, pragma_dispatch, gcc_pragmas,
	top_pragmas, do_pragma_gcc, do_pragma_implementation,
	do_pragma_poison, do_pragma_system_header,
	do_pragma_dependency, do_sccs, do_ifdef, do_ifndef, do_else,
	dl_elif, do_endif, _cpp_unwind_if_stack, do_assert,
	do_unassert, cpp_define, cpp_undef, cpp_assert, cpp_unassert,
	cpp_defined): Update for new scheme.
	(strtoul_for_line, get_define_node, dump_macro_name,
	_cpp_check_linemarker, _cpp_parse_assertion): New.
	(_cpp_handle_directive, do_pragma_default): Delete.

	* cpphash.h (struct predicate): Now struct answer.
	(enum spell_type, struct token_spelling, struct directive,
	directive_handler): New.
	Update prototypes.  Remove unused macros.
	* cpplib.h: Update prototypes.  Remove unused macros,
	structure definitions, and fields.

	* cpperror.c (print_containing_files, v_message): Adjust.
	* cppexp.c (parse_assertion, lex, parse_escape,
	_cpp_parse_expr): Adjust.
	* cppfiles.c (open_include_file, _cpp_execute_include,
	_cpp_compare_file_date, cpp_read_file, read_include_file):
	Adjust.
	* cppinit.c (dump_special_to_buffer): Delete.
	(append_include_chain, merge_include_chains, cpp_reader_init,
	cpp_cleanup, initialize_builtins, builtin_array, cpp_start_read,
	cpp_finish, handle_option, print_help): Adjust.
	* cppmain.c (main): Adjust.

testsuite:
2000-07-03  Zack Weinberg  <zack@wolery.cumb.org>

	* testsuite/gcc.dg/cpp/19951025-1.c: Adjust regexps.
	* testsuite/gcc.dg/cpp/19990703-1.c: Likewise.
	* testsuite/gcc.dg/cpp/20000625-1.c: Likewise.
	* testsuite/gcc.dg/cpp/20000625-2.c: Likewise.

	* testsuite/gcc.dg/cpp/macro1.c,
	testsuite/gcc.dg/cpp/paste1.c, testsuite/gcc.dg/cpp/paste2.c,
	testsuite/gcc.dg/cpp/paste3.c, testsuite/gcc.dg/cpp/paste4.c,
	testsuite/gcc.dg/cpp/strify1.c,
	testsuite/gcc.dg/cpp/strify2.c: New tests.

From-SVN: r34859
2000-07-04 01:58:21 +00:00
Zack Weinberg
c31a6508ee cppfiles.c: Include splay-tree.h, not hashtab.h.
* cppfiles.c: Include splay-tree.h, not hashtab.h.
	(redundant_include_p, make_IHASH, hash_IHASH, eq_IHASH): Delete.
	(destroy_include_file_node): New.
	(_cpp_init_include_hash): Rename _cpp_init_include_table.
	Create a splay tree, not a hash table.
	(open_include_file): Look up the path in the include table,
	do the multiple include optimization here, etc.
	(cpp_included): Walk the path.
	(find_include_file): Just walk the path calling
	open_include_file, or call it directly for an absolute path.
	(_cpp_fake_ihash): Rename _cpp_fake_include and update for new
	scheme.
	(read_include_file): Update for new scheme.  Don't close the
	file unless reading fails.
	(_cpp_execute_include, cpp_read_file): Tweak for new scheme.

	* cpphash.h (struct ihash, NEVER_REINCLUDE): Delete.
	(struct include_file): New.
	(NEVER_REREAD, DO_NOT_REREAD, CPP_IN_SYSTEM_HEADER): New
	macros.
	(CPP_PEDANTIC, CPP_WTRADITIONAL): Update.
	Update prototypes.

	* cppinit.c: Include splay-tree.h.
	(cpp_reader_init, cpp_cleanup): Update.

	* cpplib.h (struct cpp_buffer): Change ihash field to
	'struct include_file *inc'.  Remove system_header_p.
	(struct cpp_reader): Change all_include_files to a
	struct splay_tree_s *.

	* cpplex.c: Update all references to cpp_buffer->ihash and/or
	cpp_buffer->system_header_p.
	(cpp_pop_buffer): Close file here, only if DO_NOT_REREAD.

From-SVN: r34636
2000-06-21 18:33:51 +00:00
Zack Weinberg
f8f769ea4e cppfiles.c: Read files in, using mmap if possible, then prescan them separately.
* cppfiles.c: Read files in, using mmap if possible, then
	prescan them separately.
	(read_file, read_with_read): New functions.
	* cpplex.c: Don't define UCHAR_MAX.
	(_cpp_read_and_prescan): Rename to _cpp_prescan.  Don't read
	the file here.

	* cppinit.c (handle_option): Automatically define __cplusplus,
	__OBJC__, __ASEEMBLER__, _LANGUAGE_FORTRAN here when we see
	the respective -lang switch.

	* cpphash.h (enum node_type, struct hashnode, _cpp_lookup
	prototype): Move to...
	* cpplib.h: ... here.  Rename struct hashnode to struct
	cpp_hashnode and give it a typedef.  Rename _cpp_lookup to
	cpp_lookup.  Add 'fe_value' slot, a union tree_node *.

From-SVN: r34228
2000-05-28 05:56:38 +00:00
Zack Weinberg
021c89ed68 cpphash.c (funlike_macroexpand): Make sure not to walk p1 past l1 when deleting whitespace and markers.
* cpphash.c (funlike_macroexpand): Make sure not to walk p1
	past l1 when deleting whitespace and markers.

From-SVN: r34027
2000-05-19 17:43:38 +00:00
Zack Weinberg
15dad1d908 cppexp.c (parse_assertion): New.
* cppexp.c (parse_assertion): New.
	(lex): Call it for CPP_HASH.  Remove CPP_ASSERTION case.
	(_cpp_parse_expr): Remove case '#'.  Don't set
	parsing_if_directive.
	* cpphash.c (collect_objlike_expansion,
	collect_funlike_expansion, collect_params,
	_cpp_create_definition): The list no longer has a trailing
	VSPACE token.
	* cpphash.h (enum node_type): Add T_ASSERTION.
	(struct hashnode): Remove aschain, add pred.
	(struct predicate): New.
	Update prototypes.

	* cpplex.c (expand_token_space): Handle both offset and
	nonoffset lists.
	(init_token_list, _cpp_free_token_list, _cpp_parse_assertion): Delete.
	(_cpp_init_toklist, _cpp_clear_toklist, _cpp_free_toklist,
	_cpp_slice_toklist, _cpp_squeeze_toklist, _cpp_equiv_tokens,
	_cpp_equiv_toklists): New.
	(_cpp_scan_line): Rename to _cpp_scan_until; add ability to
	stop at any single-character token, not just newline.
	(_cpp_lex_token): Remove special cases for #define and #if.
	(cpp_get_token): Expect # as a separate token type.  Remove
	DIRECTIVE case.
	(_cpp_get_directive_token): Remove DIRECTIVE case.
	(_cpp_lex_line, _cpp_lex_file, _cpp_init_input_buffer): Update.

	* cpplib.c (_cpp_check_directive): Set dirno and
	SYNTAX_INCLUDE bit of flags, not dir_handler and dir_flags.
	(_cpp_handle_directive): Run # <number> through the same logic
	as normal directives.
	(do_define): Don't set parsing_define_directive.  Use
	_cpp_scan_until.  The list does not have a VSPACE at the end.
	(do_if): Save, clear, and restore only_seen_white around
	_cpp_parse_expr.
	(skip_if_group): s/CPP_DIRECTIVE/CPP_HASH/
	(do_assert, do_unassert): Rewrite.

	* cpplib.h (TTYPE_TABLE): Remove CPP_ASSERTION.
	(LIST_OFFSET): New flag.
	(struct cpp_toklist): Replace dir_handler and dir_flags with
	dirno and flags.
	(struct cpp_reader): Remove parsing_if_directive and
	parsing_define_directive.

From-SVN: r33984
2000-05-18 15:55:46 +00:00
Neil Booth
f617b8e222 cpphash.c (trad_stringify, [...]): Make some pointers pointers to const.
* cpphash.c (trad_stringify, warn_trad_stringify,
	collect_params): Make some pointers pointers to const.
	* cpplex.c (auto_expand_name_space) Guaranteed to always
	expand by at least one character.
	(SPELL_CHAR, SPELL_NONE): Temporarily reverse order.
	(struct token_spelling): Use const U_CHAR * rather than PTR.
	(expand_name_space): Fix up token pointers if name space
	is moved when expanding.
	(INIT_NAME, cpp_scan_line, parse_name, parse_number,
	parse_string2, save_comment, spell_token, cpp_output_list):
	Update so the routines handle tokens with a direct pointer to
	their text, rather than an offset into the token's list's namebuf.
	(_cpp_lex_line): Rearrange for clarity.

	* cpplib.c (_cpp_check_directive): Similarly.
	(do_define): Make SYM a pointer to const.
	* cpplib.h (struct cpp_name): Replace offset with direct pointer.
	(CPP_INT, CPP_FLOAT): Spelling type should be SPELL_IDENT.
	(TOK_OFFSET): Delete.
	(TOK_NAME): Update.

From-SVN: r33901
2000-05-14 22:42:58 +00:00
Zack Weinberg
3ae1c615d9 cpphash.c (collect_funlike_expansion): Make "# is not followed by a macro argument name" a pedwarn, not an error.
* cpphash.c (collect_funlike_expansion): Make "# is not
	followed by a macro argument name" a pedwarn, not an error.
	Preserve the # in the output.  Suppress the warning if lang_asm.

	* gcc.dg/dg.exp: Scan .S files as well as .c files.
	* gcc.dg/20000510-1.S: New.

From-SVN: r33841
2000-05-11 08:43:56 +00:00
Zack Weinberg
fa5572714e cpphash.h (struct hashnode): Use struct hack for name member.
* cpphash.h (struct hashnode): Use struct hack for name
	member.
	* cpphash.c (struct hashdummy): New.
	(eq_HASHNODE): Second argument is a hashdummy, not a HASHNODE.
	(make_HASHNODE): No need to set ->name pointer.  Correct
	setting of p.
	(cpp_lookup): Make 'dummy' a struct hashdummy.  Tidy up a bit.

From-SVN: r33828
2000-05-10 19:11:02 +00:00
Zack Weinberg
12cf91fef0 cpphash.h (U): New define, to correct type of string constants.
gcc:
	* cpphash.h (U): New define, to correct type of string constants.
	(ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr): New wrapper
	routines, to do casts when passing unsigned strings to libc.
	* cppexp.c, cppfiles.c, cpphash.c, cppinit.c, cpplib.c: Use them.

	* cppfiles.c (_cpp_execute_include): Make filename an U_CHAR *.
	* cpphash.c (_cpp_quote_string): Make string an U_CHAR *.
	* cppinit.c (dump_special_to_buffer): Make macro name an U_CHAR *.
	* cpplex.c (parse_ifdef, parse_include, validate_else): Make
	second argument an U_CHAR *.

	* cppinit.c (builtin_array): Make name and value U_CHAR *, add
	length field, clean up initializer.
	(ISTABLE): Add __extension__ to designated-
	initializers version.
	* cpplex.c (CHARTAB): Likewise.

	* mbchar.c: Add dummy external declaration to the !MULTIBYTE_CHARS
	case so the file won't be empty.

include:
	* symcat.h: Remove #endif label.

From-SVN: r33657
2000-05-04 04:38:01 +00:00
Zack Weinberg
1920de4701 cpplib.h: Add accessor macros for token lists.
* cpplib.h: Add accessor macros for token lists.
	* cpplib.c, cpphash.c, cpplex.c: Use them.

From-SVN: r33630
2000-05-03 15:35:47 +00:00
Zack Weinberg
1ce4a39d07 cpphash.c (collect_params): Fix off-by-one error.
* cpphash.c (collect_params): Fix off-by-one error.
	(dump_hash_helper): Dump all four macro nodetypes.

From-SVN: r33613
2000-05-02 18:10:52 +00:00
Jakub Jelinek
9900f597fa cpphash.c (trad_stringify): Adjust p after stringification as well.
* cpphash.c (trad_stringify): Adjust p after stringification as
	well.

	* gcc.dg/cpp-tradstringify.c: New test.

From-SVN: r33612
2000-05-02 18:33:44 +02:00
Zack Weinberg
c56c2073a6 cpplib.h (CPP_POP, [...]): Delete.
* cpplib.h (CPP_POP, parse_cleanup_t): Delete.
	(cpp_buffer): Remove cleanup, seen_eof, manual_pop members.

	* cppfiles.c (file_cleanup): Delete.
	* cpphash.c (macro_cleanup): Delete.
	(collect_objlike_expansion, collect_funlike_expansion,
	macarg, scan_arguments): Remove CPP_POP case.

	* cpplex.c (null_cleanup): Delete.
	(cpp_pop_buffer): Do the work that was done in the cleanups
	here.  Call _cpp_unwind_if_stack from here.
	(_cpp_expand_to_buffer, cpp_scan_buffer_nooutput,
	cpp_scan_buffer): Run until we see CPP_EOF and the top of
	stack is the buffer _below_ the one we stacked.
	(cpp_get_token): Always pop an exhausted buffer.  Return
	CPP_EOF unless it's a macro buffer.  Don't call _cpp_handle_eof.
	* cpplib.c (skip_if_group): Don't call cpp_get_token to
	increment the line number.
	(_cpp_handle_eof): Rename to _cpp_unwind_if_stack.

	* fix-header.c (read_scan_file) [parsing getchar()]: Run until
	we see CPP_EOF and the top of stack is the buffer _below_ the
	one we stacked.
	* scan-decls.c: Likewise.

From-SVN: r33611
2000-05-02 16:09:12 +00:00
Zack Weinberg
a7abcbbf92 cpphash.c (_cpp_make_hashnode): Rename make_HASHNODE, now static.
* cpphash.c (_cpp_make_hashnode): Rename make_HASHNODE, now
	static.  Allocate the hashnode and its string in the same
	block of memory.
	(del_HASHNODE): Don't free h->name.
	(_cpp_lookup): If there is no entry for this string, create
	one, of type T_VOID.
	(_cpp_lookup_slot): Delete.
	* cpphash.h: Update prototypes.

	* cpplex.c (maybe_macroexpand): Check for hp->type == T_VOID,
	not hp == NULL.
	* cpplib.c (do_define, do_undef, do_pragma_poison, do_assert,
	do_unassert, cpp_defined): Use _cpp_lookup.  Don't create a
	node here, just fill in the value field properly.  "Delete"
	entries by setting the value field to T_VOID.  Check for
	hp->type == T_VOID, not hp == NULL.

	* Makefile.in (cpplib.o): Don't depend on $(HASHTAB_H).
	* cpperror.c, cppexp.c, cpplex.c, cpplib.c:  Don't include
	hashtab.h.

From-SVN: r33581
2000-05-01 18:20:10 +00:00
Zack Weinberg
638d694d84 cppfiles.c (redundant_include_p): Provide length of token to cpp_defined.
* cppfiles.c (redundant_include_p): Provide length of token to
	cpp_defined.
	* cpphash.c (_cpp_make_hashnode, _cpp_lookup_slot): Hash
	values are unsigned int.
	(_cpp_lookup, _cpp_lookup_slot): Do not calculate the length.
	(_cpp_lookup_slot): Do not calculate the hash, either.
	* cpphash.h: Update prototypes.
	* cpplib.c (do_define, do_undef, do_pragma_poison, do_assert):
	Hashes are unsigned int.  Calculate hash here, pass by value
	to _cpp_lookup_slot.

From-SVN: r33551
2000-04-30 17:11:25 +00:00
Zack Weinberg
d2158690ae cpphash.h (enum node_type): Take out T_MCONST.
* cpphash.h (enum node_type: Take out T_MCONST.
	(union hashval): Move into struct hashnode.
	(struct hashnode): Pack tighter.  Remove file, line, col
	members.
	* cpphash.c: Constify most of the macro-definition structures.
	(struct definition): Replace by struct object_defn
	and struct funct_defn.  Put file, line, column information
	here.  All users updated to match.
	(_cpp_create_definition, _cpp_macroexpand): Remove special
	case for #define WORD OTHERWORD.
	* cpplib.c (do_undef): Remove T_MCONST case.

From-SVN: r33538
2000-04-30 01:34:00 +00:00
Zack Weinberg
5cebbd8de3 cpphash.h: Move struct reflist, struct definition, and the DEFINITION typedef to cpphash.c.
* cpphash.h: Move struct reflist, struct definition, and the
	DEFINITION typedef to cpphash.c.  Use 'struct definition *' in
	union hashval.  _cpp_free_definition takes a HASHNODE pointer.
	* cpphash.c (_cpp_free_definition): Free data pointed to by
	MCONST, XCONST, MACRO, and FMACRO nodes properly.
	(_cpp_create_definition, del_HASHNODE): Just call
	_cpp_free_definition to clear out a hashnode.
	* cpplib.c (do_pragma_poison): Likewise.

From-SVN: r33536
2000-04-29 20:58:12 +00:00
Zack Weinberg
c5a047348d [multiple changes]
2000-04-25  Zack Weinberg  <zack@wolery.cumb.org>

	* cpplib.h (struct cpp_buffer): Add 'mapped' flag; fix
	commentary.

2000-04-25  Neil Booth  <NeilB@earthling.net>

	Restore previous patch, plus the following fixes:

	* cpphash.c (_cpp_create_definition): Test PREV_WHITESPACE in
	flags, not CPP_OPEN_PAREN.
	* cpplex.c (expand_token_space, init_token_list,
	cpp_free_token_list): Put the dummy token at list->tokens[-1].
	(_cpp_lex_line, _cpp_lex_file): token list is 0-based.

From-SVN: r33419
2000-04-25 19:32:36 +00:00
Neil Booth
05183359da * Revert previous patch until build failure cause determined.
From-SVN: r33411
2000-04-25 11:57:57 +00:00
Neil Booth
9c603af2ac cpphash.c: replace HSPACE_BEFORE with PREV_WHITESPACE.
* cpphash.c: replace HSPACE_BEFORE with PREV_WHITESPACE.
	* cpphash.h (_cpp_check_directive): new.
	* cpplex.c (handle_newline, cpp_free_token_list,
	init_trigraph_map, trigraph_ok, trigraph_replace,
	backslash_start, skip_block_comment, skip_line_comment,
	skip_whitespace, parse_name, parse_number, parse_string,
	copy_comment, _cpp_lex_line, spell_char, spell_string,
	spell_comment, spell_name, spell_other, _cpp_lex_file,
	_cpp_output_list): new.
	(expand_name_space): take length argument.
	(init_token_list): add comment list initialisation.
	(cpp_scan_line): use auto_expand_name_space.  PREV_WHITESPACE
	instead of HSPACE_BEFORE.

	* cpplib.c (_cpp_check_directive): new
	* cpplib.h (cpp_name, PREV_WHITESPACE, PREV_COMMENT,
	DIGRAPH, UNSIGNED_INT, TOK_NAME): new.
	(HSPACE_BEFORE): delete.
	(TTYPE_TABLE): rearrange.
	(struct cpp_toklist): update.

From-SVN: r33390
2000-04-24 22:07:36 +00:00
Zack Weinberg
a6a69fc2ad cpphash.c (collect_objlike_expansion): Add sanity check.
* cpphash.c (collect_objlike_expansion): Add sanity check.
	(special_symbol): Remove case T_CONST, T_XCONST, T_MCONST.  If
	the buffer is the empty string, return.  Mark __DATE__ and
	__TIME__ as XCONST nodes, not MCONST.
	(_cpp_macroexpand): Avoid pushing an empty buffer.
	(funlike_macroexpand): Don't pop token_buffer here.

From-SVN: r33360
2000-04-23 21:50:59 +00:00
Zack Weinberg
d9e0bd53b2 cpphash.h (struct definition): Move file, line, col members...
* cpphash.h (struct definition): Move file, line, col members...
	(struct hashnode): ... here.  Also add 'disabled' flag.
	(enum node_type): Add T_VOID, T_XCONST, T_FMACRO, and
	T_IDENTITY.  Remove T_DISABLED.
	Update prototypes.

	* cpphash.c (_cpp_dump_definition): Split out dump_DEFINITION.
	(collect_expansion): Split into collect_objlike_expansion and
	collect_funlike_expansion.
	(_cpp_macroexpand): Split out scan_arguments, stringify, and
	funlike_macroexpand.
	(_cpp_compare_defs): Rename compare_defs, make static.
	(_cpp_make_hashnode): Initialize hp->disabled.
	(macro_cleanup): Adjust for new token types.  Clear
	m->disabled.
	(_cpp_create_definition): Move code here to determine what
	sort of macro it is, and code to check for redefinitions, from
	do_define.  Implement a few simple cases without creating a
	full DEFINITION.
	(_cpp_macroexpand, special_symbol, _cpp_dump_definition):
	Handle the simple cases.
	(push_macro_expansion): Set buf->has_escapes and hp->disabled
	here.

	* cppinit.c (builtin_array): Change MCONST to XCONST
	everywhere.
	* cpplex.c (maybe_macroexpand): Handle IDENTITY macros here;
	fix check for disabled and function-like macros.
	* cpplib.c (do_define): Move most logic to
	_cpp_create_definition.
	(do_undef): Handle new special token types.

From-SVN: r33355
2000-04-23 17:03:31 +00:00
Zack Weinberg
0f89df67fc cpphash.c (trad_stringify, add_pat): New functions.
* cpphash.c (trad_stringify, add_pat): New functions.
	(collect_expansion): Restore support for -traditional syntax.
	Use trad_stringify and add_pat.
	(_cpp_macroexpand): Restore support for -traditional semantics.
	* cpplex.c (_cpp_scan_line): Don't change space_before if we
	get a COMMENT token.
	(_cpp_lex_token): Provide COMMENT tokens to caller if
	traditional and parsing_define_directive.
	(skip_comment): Warn about // comments if -Wtraditional.
	* cpplib.c (do_define): Fix typo.  Create EMPTY nodes with
	proper node type.
	(do_undef): Don't warn about undefining EMPTY nodes.

From-SVN: r33350
2000-04-22 23:02:08 +00:00
Zack Weinberg
9e62c8114f cpphash.c (struct arg, [...]): Const-ify strings.
* cpphash.c (struct arg, struct arglist): Const-ify strings.
	(warn_trad_stringify, duplicate_arg_p): New helper functions.
	(collect_expansion): Rewrite to scan over a token list.
	Remove -traditional support.
	(collect_formal_parameters): Rename to collect_params; rewrite
	to scan over a token list.
	(_cpp_create_definition): Adjust to scan a token list.
	(_cpp_macroexpand): Remove -traditional support.
	(_cpp_compare_defs): Whitespace is now canonicalized.
	(comp_def_part): Delete function.

	* cpphash.h: Update prototypes.
	* cpplex.c (init_token_list): Don't set lineno if there is no
	buffer.
	(pedantic_whitespace): New function.
	(_cpp_scan_line): Mark tokens that had hspace before.  Don't
	consume a newline.  Use pedantic_whitespace.
	(_cpp_lex_token): Remove support for -traditional macros.
	(_cpp_get_define_token): Delete.
	(_cpp_get_directive_token): Do the real work here.  Use
	pedantic_whitespace.
	(_cpp_init_input_buffer): Initialize pfile->directbuf.

	* cpplib.c (get_macro_name): Delete.
	(do_define): Read the entire line into pfile->directbuf, then
	feed the token list to _cpp_create_definition.
	* cpplib.h (HSPACE_BEFORE): new define.
	(struct cpp_reader): Add a toklist member, "directbuf".

From-SVN: r33309
2000-04-21 17:18:50 +00:00
Zack Weinberg
1368ee700d cpplib.h (enum cpp_ttype): Add token types for all punctuators.
* cpplib.h (enum cpp_ttype): Add token types for all
	punctuators.  Distinguish pp-numbers from valid C numbers.
	Give some tokens better names.  Initialize from macro.
	(struct cpp_name, cpp_token, cpp_toklist): New data
	structures.
	Update prototypes.
	* cpplex.c (bump_column, expand_name_space,
	expand_token_space, init_token_list, cpp_output_list,
	_cpp_scan_line):  New functions.
	(output_line_command): Add third argument, new line number.
	* cpphash.h: Update prototypes.
	* cppexp.c, cpphash.c, cpplib.c, scan-decls.c: Update for new
	token names.

From-SVN: r33289
2000-04-20 19:33:11 +00:00
Zack Weinberg
0d5a06bd0b cpphash.c (special_symbol): Represent an empty macro with "\r \r " not just "\r ".
* cpphash.c (special_symbol): Represent an empty macro with
	"\r \r " not just "\r ".
	(_cpp_macroexpand): Correct condition for the foo ( ) special
	case.
	(unsafe_chars): Handle EOF as second argument.
	(push_macro_expansion): Simplify test for removing escape at
	end.  Do not trim both escapes if there is no text in between.

	* gcc.dg/20000419-1.c: New test.

From-SVN: r33267
2000-04-19 20:53:06 +00:00
Richard Kenner
e38992e8d3 conflict.c (conflict_graph_add): Pass enum type to htab_find_slot.
* gcc/conflict.c (conflict_graph_add): Pass enum type to
	htab_find_slot.
	* gcc/cpperror.c (hashtab.h): Now include.
	* gcc/cppexp.c (hashtab.h): Likewise.
	* gcc/cpplex.c (hashtab.h): Likewise.
	* gcc/cppfiles.c (hashtab.h): Likewise.
	(find_include_file, _cpp_calc_hash, cpp_read_file): Pass enum type
	to htab_find_slot_with_hash.
	* gcc/cpphash.c (hashtab.h): Now include.
	(_cpp_lookup_slot): INSERT is now enum insert_option.
	* gcc/cpphash.h (_cpp_lookup_slot): Likewise.
	* gcc/cppinit.c (hashtab.h): Include earlier.
	(initialize_builtins): Pass enum to htab_find_slot.
	* gcc/cpplib.c (hashtab.h): Now include.
	(do_define, do_undef): Pass enum type to _cpp_lookup_slot.
	(do_pragma_poison, do_assert): Likewise.
	* gcc/emit-rtl.c (gen_rtx_CONST_INT): Pass enum to
	htab_find_slot_with_hash.
	* gcc/simplify-rtx.c (cselib_lookup_mem, cselib_lookup): Likewise.
	* gcc/tree.c (type_hash_add): Likewise.
	(build1): Minor cleanup.
	* include/hashtab.h (enum insert_option): New type.
	(htab_find_slot, htab_find_slot_with_hash): Use it.
	* libiberty/hashtab.c: Various minor cleanups.
	(htab_find_slot_with_hash): INSERT is now enum insert_option.
	(htab_find_slot): Likewise.

From-SVN: r33236
2000-04-18 16:42:00 -04:00
Zack Weinberg
9cc6e05fdf cppexp.c (lex): Don't assume tokens are NUL terminated.
* cppexp.c (lex): Don't assume tokens are NUL terminated.
	* cpplib.c (do_include, do_import, do_include_next,
	read_line_number, detect_if_not_defined): Likewise.
	* cpphash.c (collect_expansion): Likewise.
	(special_symbol, _cpp_macroexpand): Check return from
	cpp_file_buffer.
	* cpphash.h (CPP_NUL_TERMINATE, CPP_NUL_TERMINATE_Q): Delete
	macros.  Delete all uses.

	* gcc.dg/cpp-mi.c: Add two more test cases.
	* gcc.dg/cpp-mind.h, gcc.dg/cpp-mindp.h: New files.

From-SVN: r33223
2000-04-18 06:43:41 +00:00
Zack Weinberg
f2d5f0cca2 cpplex.c (cpp_output_tokens, [...]): New public interfaces.
* cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public
	interfaces.
	(safe_fwrite, output_line_command): New static functions.
	(cpp_expand_to_buffer): Now private to cpplib.
	(cpp_scan_buffer): Take a printer.

	* cpphash.h: Update prototypes.
	* cpplib.h: Update prototypes.
	(cpp_printer): New.
	(cpp_buffer): Remove last_nominal_fname.
	(cpp_reader): Remove lineno.

	* cppmain.c: Use a cpp_printer.
	* fix-header.c: No need to inhibit line commands.  Call
	cpp_start_read with no printer.

	* cpperror.c (cpp_notice_from_errno): Provide default name.
	* cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions.
	(find_include_file, cpp_read_file): Use make_IHASH.
	(file_cleanup): Set control_macro and clear
	input_stack_listing_current here.
	(_cpp_execute_include): Don't output entering-file marker.
	* cpphash.c (special_symbol): Look for the line number in the
	buffer, not the reader.
	(_cpp_macroexpand): No need to disable line commands.
	(_cpp_dump_definition): No need to generate line commands.
	(dump_hash_helper): Remove excess newline from output.
	* cppinit.c (dump_special_to_buffer): No need to generate line
	commands.
	(cpp_printer_init): New.
	(cpp_start_read): Take a printer, and start it up if it's not
	NULL.  No need to generate line commands.
	(cpp_finish): Expect no buffers stacked at all.  Take a
	printer argument, and flush the output buffer if it's not
	NULL.
	* cpplex.c (_cpp_lex_token): Return EOF if there's no buffer.
	Don't put two hashes at the beginning of an assertion.
	(cpp_get_token): Don't increment pfile->lineno or emit line
	commands here.  Return EOF if there's no buffer when we get
	EOF.
	* cpplib.c (do_define, skip_if_group):
	No need to disable line commands.
	(_cpp_output_line_command): Delete function.
	(do_line): Don't emit line commands here, but set things up so
	they will be emitted if necessary.  Use _cpp_fake_ihash to
	make unique nominal_fnames if necessary.
	(do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line
	with 0 for column, not -1.
	(_cpp_handle_eof): Don't set the control macro here.  Don't
	clear input_stack_listing_current here.  Don't emit line
	commands.

From-SVN: r33159
2000-04-14 23:29:45 +00:00
Zack Weinberg
3a2b2c7a20 cppexp.c, [...]: Replace cpp_token with cpp_ttype everywhere.
* cppexp.c, cpphash.c, cpphash.h, cpplex.c, cpplib.c,
	cpplib.h, cppmain.c, fix-header.c, scan-decls.c: Replace
	cpp_token with cpp_ttype everywhere.
	* cpperror.c, cpphash.c, cpplex.c, cpplib.c, scan-decls.c:
	Replace cpp_buf_line_and_col with CPP_BUF_LINE and/or
	CPP_BUF_COL.  Line and column numbers are unsigned int, not
	long.
	* cpplex.c (cpp_buf_line_and_col): Delete.
	* cpplib.h (struct cpp_buffer, struct cpp_reader): Change
	'long lineno' to 'unsigned int lineno'.
	(CPP_BUF_LINE, CPP_BUF_COL): New macros.

From-SVN: r33076
2000-04-11 08:29:34 +00:00
Zack Weinberg
8c389f849a cpphash.c (timestamp): Delete.
* cpphash.c (timestamp): Delete.
	(del_HASHNODE): If type is T_MCONST, free value.cpval.
	(special_symbol): Remove unnecessary braces.  Remove
	T_VERSION.  Treat T_STDC like T_CONST unless
	STDC_0_IN_SYSTEM_HEADERS.  Render both __DATE__ and __TIME__
	when one is encountered, then convert them into T_MCONST
	nodes.
	* cppinit.c (builtin_array): version_string is T_MCONST.
	__STDC__ has a "1" in its cpval.  Don't have a terminator
	entry.  Clean up which entries are dumped.
	(initialize_builtins): Only __STDC__ gets the special
	-traditional treatment.  Count the length of builtin_array.
	Render version_string here.
	* cpphash.h: Remove T_VERSION.  Add T_MCONST.
	* cpplib.h (struct cpp_reader): Remove timebuf.

From-SVN: r33047
2000-04-10 03:27:21 +00:00
Zack Weinberg
ff2b53efb1 cpphash.c (CPP_IS_MACRO_BUFFER, [...]): Delete.
* cpphash.c (CPP_IS_MACRO_BUFFER, FORWARD, PEEKC): Delete.
	(macro_cleanup): No need to cast pbuf->macro.
	(collect_expansion): Use _cpp_get_define_token.  Goto done if
	it returns VSPACE.  Remove check for trailing space after
	CPP_COMMENT.
	(_cpp_create_definition): Don't diddle flags here.  Return
	directly on error.
	(unsafe_chars): Handle c1 being EOF.
	(push_macro_expansion): Use unsafe_chars for both accidental-paste
	checks.  Don't push the buffer till after we're done with
	them.
	* cpplex.c (PEEKBUF, GETBUF, FORWARDBUF): New.
	(PEEKN, FORWARD, GETC, PEEKC): Use them.
	(cpp_push_buffer): Don't set new->alimit.  Set new->mark
	appropriately.
	(_cpp_parse_assertion): Don't NUL terminate.
	(_cpp_lex_token): Fix -traditional macro handling.  Don't skip
	hspace before calling _cpp_parse_assertion.  Remove all sets
	of only_seen_white. Treat '\f' as hspace.  Don't do anything
	special with '\n' here.
	(maybe_macroexpand): Handle T_EMPTY hash entries without
	pushing a buffer at all.
	(cpp_get_token): Handle clearing only_seen_white here.  Handle
	incrementing the line number here.  Clear
	potential_control_macro as well as only_seen_white, if
	appropriate.
	(cpp_get_non_space_token): Don't eat CPP_POP tokens.
	(_cpp_get_define_token): New function, basically like
	_cpp_get_directive_token was but doesn't eat horizontal space.
	Don't do anything with only_seen_white here.
	(_cpp_get_directive_token): Just call _cpp_get_define_token
	repeatedly till it returns non-hspace.

	* cpplib.c (PEEKN, FORWARD, GETC, PEEKC): Delete.
	(conditional_skip, skip_if_group): Return int.
	(DIRECTIVE_TABLE): Change origin of all conditional directives
	to "COND".
	(TRAD_DIRECT_P): New macro.
	(_cpp_handle_directive): Use _cpp_get_directive_token.  Issue
	an error for a bogus directive, unless -lang-asm.  Use
	TRAD_DIRECT_P. Loop calling handler functions till one returns
	zero.
	(get_macro_name): Don't diddle flags here.
	(do_define): Diddle flags here.  Use _cpp_get_directive_token.
	Create T_EMPTY nodes for #define macro /* nothing */.
	(do_undef): Don't copy the name.  Use _cpp_get_directive_token.
	Use hp->name when calling pass_thru_directive.
	(do_if, do_else, do_elif, do_ifdef, do_ifndef, conditional_skip):
	Return the result of conditional_skip and/or skip_if_group.
	Don't call _cpp_output_line_command.
	(consider_directive_while_skipping): Use _cpp_get_directive_token.
	Issue -Wtraditional warnings as appropriate.  Don't complain
	about unrecognized directives.  If we are to stop skipping,
	return the number of the directive that ended the skip.
	(skip_if_group): Use _cpp_get_directive_token.  Turn off macro
	expansion and line commands while skipping.  Return the result
	of consider_directive_while_skipping, if nonzero.
	(do_endif): Just set potential_control_macro here.
	(validate_else): Use _cpp_get_directive_token.
	(do_assert, do_unassert): Don't save pointers into the
	token_buffer across calls to the lexer.  Use
	_cpp_get_directive_token.

	* cpplib.h (cpp_buffer): Remove alimit and colno.  Make mark a
	pointer, not an offset.  Replace 'data', which was a generic
	pointer, with 'macro', which points to a struct hashnode.
	(cpp_reader): Add 'potential_control_macro' pointer.
	* cpphash.h (T_UNUSED): Replace with T_EMPTY.
	(CPP_BUF_GET, CPP_FORWARD): Delete.
	(CPP_IN_COLUMN_1, ADJACENT_TO_MARK): New macros.
	(CPP_IS_MACRO_BUFFER, CPP_SET_BUF_MARK, CPP_GOTO_BUF_MARK,
	ACTIVE_MARK_P): Update.
	(_cpp_get_define_token): New internal function.
	* cppfiles.c (read_include_file): Don't set fp->alimit or fp->colno.

From-SVN: r32965
2000-04-06 07:56:14 +00:00
Philippe De Muyter
05ecd0e9ab cpphash.c (_cpp_free_definition): Test argnames, not nargs >= 0, before freeing argnames.
2000-04-04  Philippe De Muyter  <phdm@macqel.be>

	* cpphash.c (_cpp_free_definition): Test argnames, not nargs >= 0,
	before freeing argnames.
	* cpplib.c (do_ifndef): Cast return value of xstrdup.

From-SVN: r32924
2000-04-05 05:15:09 +00:00
Zack Weinberg
07aa0b04f2 cpplib.c: Include symcat.h.
* cpplib.c: Include symcat.h.  Add 'origin' field to struct
	directive.  Add origin values to DIRECTIVE_TABLE.  Generate
	the strings and function names on the fly.  Take the #sccs
	entry out of the table if SCCS_DIRECTIVE is not defined.
	(_cpp_handle_directive): Decide if the # was at the beginning
	of the line here.  Issue -pedantic warnings for extended
	directives here.  Warn about K+R directives with the #
	indented, and C89/extended directives with the # not indented,
	here.
	(do_import, do_include_next, do_warning, do_ident, do_sccs,
	do_assert, do_unassert): Don't issue pedantic warning here.

	* cpphash.h: Add CPP_WTRADITIONAL macro.
	* cpplib.h (struct cpp_options): Rename warn_stringify to
	warn_traditional; update comments.
	* cppinit.c (handle_option): Set warn_traditional not
	warn_stringify.
	* cpphash.c: Replace CPP_OPTION (pfile, warn_stringify) with
	CPP_WTRADITIONAL (pfile).
	* cpplex.c (_cpp_lex_token): Don't decide if directives should
	be ignored in -traditional mode here.

	* cpplex.c: Copy ISTABLE macros from cppinit.c, and adapt them
	to initialize speccase[] and trigraph_map[].  Delete all
	references to pfile->input_speccase.  Always treat '?' as a
	special character.  Remove table-initialization code from
	_cpp_init_input_buffer.

	* cpplib.h (struct cpp_reader): Remove input_speccase field.
	* cppinit.c (cpp_cleanup): Don't free input_speccase.

From-SVN: r32860
2000-04-01 22:55:25 +00:00
Zack Weinberg
ae79697b72 cpplib.h: Merge struct cpp_options into struct cpp_reader.
* cpplib.h: Merge struct cpp_options into struct cpp_reader.
	Reorder struct cpp_options and struct cpp_reader for better
	packing.  Replace CPP_OPTIONS macro with CPP_OPTION which
	takes two args.  Change all 'char' flags to 'unsigned char'.
	Move show_column flag into struct cpp_options.  Don't
	prototype cpp_options_init.
	* cpphash.h, cpperror.c, cppexp.c, cppfiles.c, cpphash.c,
	cppinit.c, cpplex.c, cpplib.c:
	Replace CPP_OPTIONS (pfile)->whatever with
	CPP_OPTION (pfile, whatever), and likewise for
	opts = CPP_OPTIONS (pfile); ... opts->whatever;

	* cppinit.c (merge_include_chains): Take a cpp_reader *.
	Extract CPP_OPTION (pfile, pending) and work with that
	directly.
	(cpp_options_init): Delete.
	(cpp_reader_init): Turn on on-by-default options here.
	Allocate the pending structure here.
	(cl_options, enum opt_code): Define these from the same table,
	kept in a large macro.  Add -fshow-column and -fno-show-column
	options.

	* cpperror.c (v_message): If show_column is off, don't print
	the column number.

	* cppmain.c: Update for new interface.
	* fix-header.c: Likewise.

From-SVN: r32850
2000-03-31 23:16:11 +00:00
Zack Weinberg
29a72a4f09 cppfiles.c (hash_IHASH): Just return i->hash.
2000-03-28  Zack Weinberg  <zack@wolery.cumb.org>

	* cppfiles.c (hash_IHASH): Just return i->hash.
	(cpp_included): Set dummy.hash using _cpp_calc_hash.  Use
	htab_find_with_hash.
	(cpp_read_file): Likewise.
	(find_include_file): Likewise.  Properly initialize
	ih->nshort.  Share ih->name and ih->nshort if possible.
	* cpphash.c (_cpp_calc_hash): New function.
	(hash_HASHNODE): Just return h->hash.
	(_cpp_lookup): Set dummy.hash using _cpp_calc_hash.  Use
	htab_find_with_hash.
	* cpphash.h: Prototype _cpp_calc_hash.
	* cppinit.c (initialize_builtins): Provide a valid hash
	to _cpp_make_hashnode, using _cpp_calc_hash.

	* cpphash.c (collect_expansion): # is not a special character
	in object-like macros.  In -traditional mode, /**/ is not
	token paste at the beginning or end of the line.
	* cpplib.c (do_include, do_import, do_include_next): If
	parse_include fails, return immediately.

From-SVN: r32792
2000-03-28 21:45:02 +00:00
Jason Merrill
1a7b4c697c * cpphash.c (dump_hash_helper): Take the slot, not the element.
From-SVN: r32566
2000-03-15 16:54:47 -05:00
Alexandre Oliva
1690826f33 cpphash.c (collect_formal_parameters): Do not complain about parameter names that just start with `__VA_ARGS__'.
* cpphash.c (collect_formal_parameters): Do not complain about
parameter names that just start with `__VA_ARGS__'.

From-SVN: r32563
2000-03-15 18:46:09 +00:00
Zack Weinberg
194ae3f644 cpphash.c (dump_hash_helper): Only dump nodes of type T_MACRO.
* cpphash.c (dump_hash_helper): Only dump nodes of type
	T_MACRO.  Emit a newline after each definition.

From-SVN: r32518
2000-03-14 06:10:27 +00:00