Commit Graph

35 Commits

Author SHA1 Message Date
Zack Weinberg 6d4587f735 cppinit.c (cpp_post_options): Shut off macro expansion if -fpreprocessed.
* cppinit.c (cpp_post_options): Shut off macro expansion if
	-fpreprocessed.
	* cpplib.c (_cpp_handle_directive): If -fpreprocessed, accept
	IN_I directives only if the # is in column 1 and the directive
	name begins in column 2.
	* cppmain.c (scan_buffer): Insert a space between # and an
	identifier, when that identifier is a directive name.

	* tradcpp.c (struct file_buf): Add a pointer to the next entry
	in the header search path.
	(enum node_type): Add T_INCLUDE_NEXT.
	(directive_table): Add entry for include_next.
	(do_include_next): New function.
	(process_include): New routine, broken out of do_include.
	(finclude): Insert 'nhd' argument, to be copied into
	next_header_dir of the new buffer.
	(main): Adjust to match.
	* gsyslimits.h, limity.h: Un-indent #include_next.

testsuite:
	* gcc.dg/cpp/direct2.c: New test.
	* gcc.dg/cpp/direct2s.c: New test.

	* gcc.c-torture/execute/920730-1t.c: #undef __GNUC__ at head.

From-SVN: r41932
2001-05-10 00:07:23 +00:00
Jakub Jelinek 2d2a86ae79 tradcpp.c (do_define): Make sure we don't walk past limit.
* tradcpp.c (do_define): Make sure we don't walk past limit.

	* gcc.dg/cpp/tr-define.c: New test.

From-SVN: r41773
2001-05-02 22:50:01 +02:00
Kaveh R. Ghazi 3fdefbcc63 toplev.h (fatal_error): Add ATTRIBUTE_NORETURN.
* toplev.h (fatal_error): Add ATTRIBUTE_NORETURN.

	* tradcif.y (yyerror): Likewise.  Add format specifier in call to
	`error'.

	* tradcpp.c (macroexpand): Likewise for call to `error_with_line'.

From-SVN: r40939
2001-03-28 19:24:11 +00:00
Jakub Jelinek 7855db7cb8 cppfiles.c (_cpp_read_file): Add to dependencies if requested.
* cppfiles.c (_cpp_read_file): Add to dependencies if requested.
	* cppinit.c (cpp_start_read): Remove deps_add_dep call.
	* tradcpp.c (main): Add -imacros or -include'd dependencies
	for -M*.
	* cpp.texi (-M, -MM): Document -M -include behaviour.

From-SVN: r39240
2001-01-24 19:44:40 +01:00
Neil Booth 05e8172427 [multiple changes]
2001-01-11  Neil Booth  <neil@daikokuya.demon.co.uk>

        * cppinit.c (cpp_start_read): If -fpreprocessed, ignore
	-D, -U and -A, and don't initialize the builtins.
	* cppmain.c (cb_define, cb_undef): Unconditionally process
	the callback.
	* tradcpp.c (main): Fix typo.

2000-01-11  Mark Elbrecht  <snowball3@bigfoot.com>

        * cppfiles.c (cpp_included, find_include_file, _cpp_execute_include)
          (read_name_map): Use IS_ABSOLUTE_PATH.
        * tradcpp.c (get_filename): Likewise.

From-SVN: r38925
2001-01-11 21:30:16 +00:00
Neil Booth 2f638f9664 Makefile.in (tradcpp0): Depend on mkdeps.h.
* Makefile.in (tradcpp0): Depend on mkdeps.h.  Link mkdeps.o
        * cppinit.c (cpp_start_read): Update comment, remove unneeded
        if statement.
        * tradcpp.c: Include mkdeps.h.
        (deps, print_deps_phony_targets, deps_append, output_deps,
        init_dependency_output, output_deps): New.
        (deps_buffer, deps_allocated_size, deps_size, deps_column,
        deps_output): Delete.
        (print_deps_missing_files): Rename deps_missing_files.
        (inhibit_output): Make global.
        (main): Delete inhibit_output, deps_stream, deps_target.
        Use mkdeps functionality in the same way as cpplib.  Remove
        -g3 handling.  Handle -MF, -MP, -MQ, -MT.  Update handling of
        -M and -MM.  Remove old handling of deps via deps_out, and
        old reading of environment variables.
        (get_filename): Update to use deps_add_dep.

From-SVN: r38885
2001-01-10 23:28:00 +00:00
Jakub Jelinek c3843cea61 tradcpp.c (deps_file, [...]): New variables.
* tradcpp.c (deps_file, print_deps_missing_files): New variables.
	(main): Handle -MG, -MD, -MMD.  Bail out if -MG is given without -M
	or -MM.
	(do_include): Handle missing headers like cpp0.
	* cppfiles.c (_cpp_execute_include): Don't prefix absolute header
	paths with first include pathname.  Don't strcat to uninitialized
	string.

From-SVN: r38683
2001-01-04 18:26:12 +01:00
Franz Sirl fa5db8286c tradcpp.c (main): Make sure finclude() is called with a valid indepth value while handling -include.
2001-01-03  Franz Sirl  <Franz.Sirl-kernel@lauterbach.com>

	* tradcpp.c (main): Make sure finclude() is called with a valid
	indepth value while handling -include.

From-SVN: r38674
2001-01-03 22:26:05 +00:00
Neil Booth 3244472df9 tradcpp.c: T_WARNING: New.
* tradcpp.c: T_WARNING: New.
        (do_warning): New function.
        (finclude): Skip past the newline and increase the line number
        before calling output_line_command.
        (do_line): Skip the new line after output_line_command.  Don't
        pre-decrement the line number.

From-SVN: r38305
2000-12-16 10:41:56 +00:00
Neil Booth c36ee1647b tradcpp.c (special_symbol): Improve test for definedness, though it is still not perfect.
* tradcpp.c (special_symbol): Improve test for definedness,
        though it is still not perfect.
        (do_define): Don't define illegal macro names.

From-SVN: r38230
2000-12-13 19:47:11 +00:00
Brad Lucier 1df97aa412 tradcpp.c (do_error): Cast difference of pointers to int for error message.
* tradcpp.c (do_error): Cast difference of pointers to int
        for error message.

From-SVN: r38212
2000-12-12 23:17:00 +00:00
Neil Booth e793c60979 tradcpp.c (enum node_type): Add T_ERROR.
* tradcpp.c (enum node_type): Add T_ERROR.
        (do_error): New function.
        (directive_table): Add #error handler.

From-SVN: r38205
2000-12-12 18:54:26 +00:00
Brad Lucier 2bff3fd527 * tradcpp.c (do_include): Make pointer differences 64-bit clean.
From-SVN: r38133
2000-12-08 18:42:13 +00:00
Zack Weinberg f6bbde28c4 safe-ctype.h: New file.
include:
	* safe-ctype.h: New file.
libiberty:
	* safe-ctype.c: New file.
	* Makefile.in (CFILES): Add safe-ctype.c.
	(REQUIRED_OFILES): Add safe-ctype.o.

	* argv.c: Define ISBLANK and use it, not isspace.
	* basename.c, cplus-dem.c, fnmatch.c, pexecute.c, strtod.c,
	strtol.c, strtoul.c: Include safe-ctype.h, not ctype.h.  Use
	uppercase ctype macros.  Don't test ISUPPER(c)/ISLOWER(c)
	before calling TOLOWER(c)/TOUPPER(c).
gcc:
	* Makefile.in (HOST_RTL): Add safe-ctype.o.
	(safe-ctype.o): New rule.
	* system.h: Include safe-ctype.h, not ctype.h.  No need to
	wrap ctype macros.

	* cpphash.h: Zap IStable and related macros.  Define is_* in
	terms of safe-ctype.h macros.
	* cppinit.c: Delete the IStable and all related code.

	* tradcpp.c: Delete is_idchar, is_idstart, is_hor_space, and
	is_space arrays.  Delete initialize_char_syntax.  Change all
	references to the above arrays to use macros instead.
	* tradcpp.h: Define is_idchar, is_idstart, is_space, and
	is_nvspace in terms of safe_ctype.h's macros.
	* tradcif.y: is_idchar, is_idstart are macros not arrays.

	* config/i370/i370.c, config/winnt/dirent.c,
	config/winnt/fixinc-nt.c, config/winnt/ld.c:
	Use uppercase ctype macros.  If we included ctype.h,
	include safe-ctype.h instead.

	* fixinc/fixfixes.c: Use uppercase ctype macros.  Don't test
	ISLOWER(c) before calling TOUPPER(c).
	* fixinc/fixincl.c (extract_quoted_files): Simplify out some gunk.
	* fixinc/gnu-regex.c: Include safe-ctype.h, not ctype.h.  No need to
	wrap ctype macros.  Don't test ISUPPER(x) before calling TOLOWER(x).
gcc/ch:
	* lex.c: Don't bother checking whether ISUPPER(c) before
	calling TOLOWER(c).  Don't bother checking whether isascii(c)
	before testing ISSPACE(c); ISSPACE(c) includes '\n'.
gcc/f:
	* Make-lang.in: Link f/fini with safe-ctype.o.
	* bad.c: Don't test ISUPPER(c) || ISLOWER(c) before calling TOUPPER(c).
	* com.c: Use TOUPPER, not ffesrc_toupper.
	* fini.c: Don't test ISALPHA(c) before calling TOUPPER(c)/TOLOWER(c).
	* intrin.c: Don't test IN_CTYPE_DOMAIN(c).
	* src.c: Delete ffesrc_toupper_ and ffesrc_tolower_ and their
	initializing code; use TOUPPER and TOLOWER instead of
	ffesrc_toupper and ffesrc_tolower.
	* src.h: Don't declare ffesrc_toupper_ or ffesrc_tolower_.
	Don't define ffesrc_toupper or ffesrc_tolower.
gcc/java:
	* jvgenmain.c: Use ISPRINT not isascii.

From-SVN: r38124
2000-12-08 03:00:26 +00:00
Neil Booth 7682e7bc2e tradcif.y: Move lexptr to top of file.
* tradcif.y: Move lexptr to top of file.  Add rule to handle
        assertions in conditional expressions.
        * tradcpp.c (parse_answer): Assertions do not need to go to
        end of line in conditional directives.
        (parse_assertion): Get first character of identifiers correct.
        (test_assertion): New function.
        * tradcpp.h (test_assertion): New prototype.

From-SVN: r38011
2000-12-04 22:05:19 +00:00
Neil Booth 4eb191f350 tradcpp.c (struct answer, [...]): New.
* tradcpp.c (struct answer, parse_assertion, parse_answer,
        canonicalize_text, find_answer): New.
        (do_assert, do_unassert): Provide appropriate function bodies.
        (union hashval): New member answers.

From-SVN: r37953
2000-12-02 16:04:14 +00:00
Neil Booth 40bd439555 tradcpp.c (enum node_type): New hash types T_ASSERT, T_UNASSERT.
* tradcpp.c (enum node_type): New hash types T_ASSERT, T_UNASSERT.
        (struct directive): Drop 4th argument from handlers.
        (do_define, do_line, do_include, do_undef, do_else, do_elif,
        do_endif): Similarly.
        (do_assert, do_unassert, do_ifdef, do_ifndef): New handlers.
        (do_ifxdef): Update as common handler of do_ifdef and do_ifndef.
        (make_definition, make_undef): Take a const char*.
        (make_assertion): New function.
        (struct directive_table): Update.
        (main): Handle -A command line argument.
        (handle_directive): Drop fourth handler argument.

From-SVN: r37820
2000-11-28 19:14:16 +00:00
Neil Booth fb6a7b08a8 tradcpp.c (enum pending_dir_t, [...]): New.
* tradcpp.c (enum pending_dir_t, struct pending_dir): New.
        (main): Allocate a pending directive set of these.  Use it.
        Merge handling of -D and -U.  Update handling of pending
        directives.  Free the memory after use.

From-SVN: r37803
2000-11-27 19:04:54 +00:00
Kaveh R. Ghazi b3e2d1eb53 tradcpp.c (output_line_command): Mark system headers as such in `line' commands.
* tradcpp.c (output_line_command): Mark system headers as such in
	`line' commands.

From-SVN: r37616
2000-11-21 15:55:08 +00:00
Kaveh R. Ghazi ce1cc601f5 Warning fixes:
* builtins.c (c_getstr): Constify variable.
	* gmon-sol2.c (_mcleanup): Comment out #endif labels.
	* conflict.c (const_conflict_graph_arc): New typedef.
	(arc_hash, arc_eq): Avoid needlessly casting away const-ness.
	* cppmacro.c (builtin_macro): Likewise.
	* dwarf2out.c (output_comp_unit): Constify variable.
	* fix-header.c (v_fatal): Add ATTRIBUTE_PRINTF.
	* protoize.c (IS_SAME_PATH_CHAR): Use TOUPPER, not toupper.
	* ssa.c (ssa_rename_from_hash_function): Avoid needlessly casting
	away const-ness.
	* tradcpp.c (rescan, do_line, macroexpand, macarg): Use
	ISALNUM/ISDIGIT/ISPRINT, not isalnum/isdigit/isprint.
	* varasm.c (const_str_htab_hash, const_str_htab_eq,
	compare_constant_1, record_constant_1): Constify.

From-SVN: r37565
2000-11-19 13:15:51 +00:00
Kaveh R. Ghazi 0a8ad41790 Makefile.in (tradcpp.o, tradcif.o): Depend on tradcpp.h.
* Makefile.in (tradcpp.o, tradcif.o): Depend on tradcpp.h.

	* tradcif.y: Include tradcpp.h.  Constify.  Make functions static.
	Move extern function declarations to tradcpp.h.

	* tradcpp.c: Likewise.

	* tradcpp.h: New file.

From-SVN: r37550
2000-11-19 00:30:05 +00:00
Zack Weinberg ef90743a44 tradcpp.c, tradcif.y: Update FSF mailing address, delete reference to GPLv1.
* tradcpp.c, tradcif.y: Update FSF mailing address, delete
	reference to GPLv1.

From-SVN: r37455
2000-11-14 17:01:35 +00:00
Joseph Myers 88f3c47786 diagnostic.c (vbuild_message_string, [...]): Add ATTRIBUTE_PRINTF.
* diagnostic.c (vbuild_message_string, output_do_printf, vnotice):
	Add ATTRIBUTE_PRINTF.
	* tradcpp.c (v_message, warning, error, fatal, error_with_line):
	Add ATTRIBUTE_PRINTF*.

java:
	* parse.y (issue_warning_error_from_context): Add
	ATTRIBUTE_PRINTF.

From-SVN: r37419
2000-11-13 13:23:37 +00:00
Neil Booth ea33bfc554 tradcpp.c (special_symbol): Assign an null string rather than writing to an unallocated buffer.
* tradcpp.c (special_symbol): Assign an null string rather
        than writing to an unallocated buffer.

From-SVN: r37278
2000-11-06 18:58:28 +00:00
Zack Weinberg 2c8f0515bb cpperror.c (print_file_and_line): If line is (unsigned int)-1, print just 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-29 18:37:37 +00:00
Joseph Myers d677797245 cppdefault.h (WINT_TYPE): Define.
* cppdefault.h (WINT_TYPE): Define.
	* cppinit.c (builtin_array): Define __WINT_TYPE__.
	* tradcpp.c (initialize_builtins): Define __WINT_TYPE__.
	* tm.texi (NO_BUILTIN_WINT_TYPE, WINT_TYPE): Document.

From-SVN: r35478
2000-08-04 13:45:57 +01:00
Jakub Jelinek 9512cb3f2f tradcpp.c (main): Update max_include_len for cpp_include_defaults as well.
* tradcpp.c (main): Update max_include_len for cpp_include_defaults
	as well.

From-SVN: r35229
2000-07-24 19:04:03 +02:00
Zack Weinberg fbfc11925b diagnostic.c (trim_filename, [...]): Moved here from rtl.c.
* diagnostic.c (trim_filename, fancy_abort): Moved here from
	rtl.c.
	(fatal_function, set_fatal_function): Removed.
	(fatal): Don't prepare for or call the fatal_function.
	(diagnostic_lock, error_recursion): New.
	(diagnostic_for_decl, report_diagnostic): Guard against
	re-entering the error reporting routines.
	(fancy_abort): Assume function is not NULL.

	* errors.c (fancy_abort): New.  Assume function is not NULL.
	* tradcpp.c (fancy_abort): Assume function is not NULL.

	* system.h: Provide default definition of __FUNCTION__.
	* rtl.h: Use __FUNCTION__ not __PRETTY_FUNCTION__ throughout.
	Always use __FUNCTION__ in definition of abort.
	* tree.h: Likewise.
	* varray.h: Likewise.
	* toplev.h: Likewise.  Don't prototype set_fatal_function.

From-SVN: r35170
2000-07-21 07:10:36 +00:00
Zack Weinberg 1e18a243c2 [multiple changes]
2000-07-20  Zack Weinberg  <zack@wolery.cumb.org>

	* tradcpp.c (main): Don't munge -D options.
	(make_definition): Bring -D handling in line with cpplib.
	(do_define): Strip all leading whitespace from macro definitions.

2000-07-20  David Billinghurst <David.Billinghurst@riotinto.com.au>

	* Makefile.in (tradcpp): Depend on intl.o and version.o.

From-SVN: r35145
2000-07-20 17:14:23 +00:00
Zack Weinberg 53fdf0be63 tradcpp.c (rescan): Do not recognize directives when the # is indented.
* tradcpp.c (rescan): Do not recognize directives when the #
	is indented.

	* gcc.dg/cpp/tr-direct.c: New test.

From-SVN: r35139
2000-07-19 20:37:26 +00:00
Zack Weinberg c334349bda gcc.c (execute): If a subprocess gets a fatal signal...
* gcc.c (execute): If a subprocess gets a fatal signal, report
	strsignal() of the signal number, and ask for a bug report.
	Do not do this for SIGPIPE if there's already been an error.

	* tradcpp.c: Don't include signal.h.  Don't catch SIGPIPE.
	Delete pipe_closed.

From-SVN: r35006
2000-07-13 04:43:47 +00:00
Zack Weinberg 6e993bdb62 * tradcpp.c (main): Rename 'perror' label to 'sys_error'.
From-SVN: r35004
2000-07-13 03:06:25 +00:00
Kaveh R. Ghazi 5c7525acc1 tradcpp.c (main): Rename label `include' to `add_include' to avoid conflicts with variable...
* tradcpp.c (main): Rename label `include' to `add_include' to
	avoid conflicts with variable `include' in traditional C.

From-SVN: r34908
2000-07-07 20:13:35 +00:00
Zack Weinberg 09bb5d9a8f tradcpp.c (initialize_builtins): Honor NO_BUILTIN_SIZE_TYPE and friends.
* tradcpp.c (initialize_builtins): Honor NO_BUILTIN_SIZE_TYPE
	and friends.

From-SVN: r34905
2000-07-07 19:36:12 +00:00
Zack Weinberg 24c3c71a8c tradcpp.c: New file.
* tradcpp.c: New file.
	* tradcif.y: New file.
	* tradcif.c: New generated file.

	* Makefile.in: Add rules to build tradcpp.o, tradcif.o,
	$(srcdir)/tradcif.c.  Add tradcpp to STAGESTUFF and
	dependencies of C.  Install tradcpp from install-common, in
	$(libsubdir).

From-SVN: r34893
2000-07-06 22:59:34 +00:00