Commit f4ff5a69 by Neil Booth Committed by Neil Booth

c-opts.c (deps_seen, [...]): New.

	* c-opts.c (deps_seen, deps_file, deferred_count, deferred_size,
	handle_deferred_opts, sanitize_cpp_opts, defer_opt,
	struct deferred_opt): New.
	(COMMAND_LINE_OPTIONS): Add -M*.
	(missing_arg): Update.
	(c_common_decode_option): Handle -M*.
	(c_common_post_options): Handle -M*.  Use sanitize_cpp_opts;
	don't call cpp_post_options.
	(c_common_finish, check_deps_environment_vars): Update.
	* cppfiles.c (stack_include_file, handle_missing_header): Update.
	* cpphash.h (CPP_PRINT_DEPS): Remove.
	* cppinit.c: Don't include version.h.
	(cpp_create_reader): Don't call deps_init.  Initialize
	warn_long_long.
	(cpp_read_main_file): Init deps if necessary.
	(cpp_destroy): Conditionally free deps.
	(cpp_finish): Update.
	(no_tgt): Remove.
	(COMMAND_LINE_OPTIONS, cpp_handle_option): Remove -M*.
	(cpp_post_options): Rename post_options.
	* cpplib.h (struct cpp_options): Remove some dependency options;
	move others to a new structure.
	(cpp_post_options): Remove.
	(cpp_finish): Comment.
	* fix-header.c (read_scan_file): Don't call cpp_post_options.
treelang:
	* treelang.c: Remove cpp_post_options.

From-SVN: r56239
parent 34116c2a
2002-08-13 Neil Booth <neil@daikokuya.co.uk>
* c-opts.c (deps_seen, deps_file, deferred_count, deferred_size,
handle_deferred_opts, sanitize_cpp_opts, defer_opt,
struct deferred_opt): New.
(COMMAND_LINE_OPTIONS): Add -M*.
(missing_arg): Update.
(c_common_decode_option): Handle -M*.
(c_common_post_options): Handle -M*. Use sanitize_cpp_opts;
don't call cpp_post_options.
(c_common_finish, check_deps_environment_vars): Update.
* cppfiles.c (stack_include_file, handle_missing_header): Update.
* cpphash.h (CPP_PRINT_DEPS): Remove.
* cppinit.c: Don't include version.h.
(cpp_create_reader): Don't call deps_init. Initialize
warn_long_long.
(cpp_read_main_file): Init deps if necessary.
(cpp_destroy): Conditionally free deps.
(cpp_finish): Update.
(no_tgt): Remove.
(COMMAND_LINE_OPTIONS, cpp_handle_option): Remove -M*.
(cpp_post_options): Rename post_options.
* cpplib.h (struct cpp_options): Remove some dependency options;
move others to a new structure.
(cpp_post_options): Remove.
(cpp_finish): Comment.
* fix-header.c (read_scan_file): Don't call cpp_post_options.
2002-08-12 Hans-Peter Nilsson <hp@bitrange.com>
* config/mmix/mmix.md (define_constants): Add MMIX_rR_REGNUM.
......
......@@ -2211,7 +2211,7 @@ cpphash.o: cpphash.c $(CONFIG_H) $(LIBCPP_DEPS)
cpptrad.o: cpptrad.c $(CONFIG_H) $(LIBCPP_DEPS)
cppfiles.o: cppfiles.c $(CONFIG_H) $(LIBCPP_DEPS) $(SPLAY_TREE_H) mkdeps.h
cppinit.o: cppinit.c $(CONFIG_H) $(LIBCPP_DEPS) cppdefault.h \
mkdeps.h prefix.h version.h
mkdeps.h prefix.h
cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) cppdefault.h Makefile
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
......
......@@ -319,7 +319,7 @@ stack_include_file (pfile, inc)
(inc->foundhere ? inc->foundhere->sysp : 0));
/* For -M, add the file to the dependencies on its first inclusion. */
if (CPP_OPTION (pfile, print_deps) > !!sysp && !inc->include_count)
if (CPP_OPTION (pfile, deps.style) > !!sysp && !inc->include_count)
deps_add_dep (pfile->deps, inc->name);
/* Not in cache? */
......@@ -663,9 +663,10 @@ handle_missing_header (pfile, fname, angle_brackets)
const char *fname;
int angle_brackets;
{
int print_dep = CPP_PRINT_DEPS(pfile) > (angle_brackets || pfile->map->sysp);
if (CPP_OPTION (pfile, print_deps_missing_files) && print_dep)
bool print_dep
= CPP_OPTION (pfile, deps.style) > (angle_brackets || pfile->map->sysp);
if (CPP_OPTION (pfile, deps.missing_files) && print_dep)
deps_add_dep (pfile->deps, fname);
/* If -M was specified, then don't count this as an error, because
we can still produce correct output. Otherwise, we can't produce
......@@ -673,7 +674,7 @@ handle_missing_header (pfile, fname, angle_brackets)
the missing file, and we don't know what directory this missing
file exists in. */
else
cpp_errno (pfile, CPP_PRINT_DEPS (pfile) && ! print_dep
cpp_errno (pfile, CPP_OPTION (pfile, deps.style) && ! print_dep
? DL_WARNING: DL_ERROR, fname);
}
......
......@@ -400,7 +400,7 @@ struct cpp_reader
cpp_token avoid_paste;
cpp_token eof;
/* Opaque handle to the dependencies of mkdeps.c. Used by -M etc. */
/* Opaque handle to the dependencies of mkdeps.c. */
struct deps *deps;
/* Obstack holding all macro hash nodes. This never shrinks.
......@@ -480,7 +480,6 @@ extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
/* Macros. */
#define CPP_PRINT_DEPS(PFILE) CPP_OPTION (PFILE, print_deps)
#define CPP_IN_SYSTEM_HEADER(PFILE) ((PFILE)->map && (PFILE)->map->sysp)
#define CPP_PEDANTIC(PF) CPP_OPTION (PF, pedantic)
#define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional)
......
......@@ -25,7 +25,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "cpphash.h"
#include "prefix.h"
#include "intl.h"
#include "version.h"
#include "mkdeps.h"
#include "cppdefault.h"
......@@ -108,6 +107,7 @@ static void new_pending_directive PARAMS ((struct cpp_pending *,
const char *,
cl_directive_handler));
static int parse_option PARAMS ((const char *));
static void post_options PARAMS ((cpp_reader *));
/* Fourth argument to append_include_chain: chain to use.
Note it's never asked to append to the quote chain. */
......@@ -477,6 +477,7 @@ cpp_create_reader (lang)
CPP_OPTION (pfile, tabstop) = 8;
CPP_OPTION (pfile, operator_names) = 1;
CPP_OPTION (pfile, warn_endif_labels) = 1;
CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99);
CPP_OPTION (pfile, pending) =
(struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
......@@ -490,10 +491,6 @@ cpp_create_reader (lang)
CPP_OPTION (pfile, unsigned_char) = 0;
CPP_OPTION (pfile, unsigned_wchar) = 1;
/* It's simplest to just create this struct whether or not it will
be needed. */
pfile->deps = deps_init ();
/* Initialise the line map. Start at logical line 1, so we can use
a line number of zero for special states. */
init_line_maps (&pfile->line_maps);
......@@ -560,7 +557,8 @@ cpp_destroy (pfile)
pfile->macro_buffer_len = 0;
}
deps_free (pfile->deps);
if (pfile->deps)
deps_free (pfile->deps);
obstack_free (&pfile->buffer_ob, 0);
_cpp_destroy_hashtable (pfile);
......@@ -902,6 +900,8 @@ cpp_read_main_file (pfile, fname, table)
{
sanity_checks (pfile);
post_options (pfile);
/* The front ends don't set up the hash table until they have
finished processing the command line options, so initializing the
hashtable is deferred until now. */
......@@ -927,17 +927,22 @@ cpp_read_main_file (pfile, fname, table)
fprintf (stderr, _("End of search list.\n"));
}
if (CPP_OPTION (pfile, print_deps))
/* Set the default target (if there is none already). */
deps_add_default_target (pfile->deps, fname);
if (CPP_OPTION (pfile, deps.style) != DEPS_NONE)
{
if (!pfile->deps)
pfile->deps = deps_init ();
/* Set the default target (if there is none already). */
deps_add_default_target (pfile->deps, fname);
}
/* Open the main input file. */
if (!_cpp_read_file (pfile, fname))
return NULL;
/* Set this after cpp_post_options so the client can change the
option if it wishes, and after stacking the main file so we don't
trace the main file. */
/* Set this here so the client can change the option if it wishes,
and after stacking the main file so we don't trace the main
file. */
pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names);
/* For foo.i, read the original filename foo.c now, for the benefit
......@@ -1067,11 +1072,12 @@ cpp_finish (pfile, deps_stream)
_cpp_pop_buffer (pfile);
/* Don't write the deps file if there are errors. */
if (deps_stream && CPP_OPTION (pfile, print_deps) && !pfile->errors)
if (CPP_OPTION (pfile, deps.style) != DEPS_NONE
&& deps_stream && pfile->errors == 0)
{
deps_write (pfile->deps, deps_stream, 72);
if (CPP_OPTION (pfile, deps_phony_targets))
if (CPP_OPTION (pfile, deps.phony_targets))
deps_phony_targets (pfile->deps, deps_stream);
}
......@@ -1106,7 +1112,6 @@ new_pending_directive (pend, text, handler)
#define no_fil N_("file name missing after %s")
#define no_mac N_("macro name missing after %s")
#define no_pth N_("path name missing after %s")
#define no_tgt N_("target missing after %s")
/* This is the list of all command line options, with the leading
"-" removed. It must be sorted in ASCII collating order. */
......@@ -1114,15 +1119,6 @@ new_pending_directive (pend, text, handler)
DEF_OPT("A", no_ass, OPT_A) \
DEF_OPT("D", no_mac, OPT_D) \
DEF_OPT("I", no_dir, OPT_I) \
DEF_OPT("M", 0, OPT_M) \
DEF_OPT("MD", no_fil, OPT_MD) \
DEF_OPT("MF", no_fil, OPT_MF) \
DEF_OPT("MG", 0, OPT_MG) \
DEF_OPT("MM", 0, OPT_MM) \
DEF_OPT("MMD", no_fil, OPT_MMD) \
DEF_OPT("MP", 0, OPT_MP) \
DEF_OPT("MQ", no_tgt, OPT_MQ) \
DEF_OPT("MT", no_tgt, OPT_MT) \
DEF_OPT("U", no_mac, OPT_U) \
DEF_OPT("idirafter", no_dir, OPT_idirafter) \
DEF_OPT("imacros", no_fil, OPT_imacros) \
......@@ -1272,44 +1268,6 @@ cpp_handle_option (pfile, argc, argv)
CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
break;
case OPT_MG:
CPP_OPTION (pfile, print_deps_missing_files) = 1;
break;
case OPT_M:
/* When doing dependencies with -M or -MM, suppress normal
preprocessed output, but still do -dM etc. as software
depends on this. Preprocessed output occurs if -MD, -MMD
or environment var dependency generation is used. */
CPP_OPTION (pfile, print_deps) = 2;
CPP_OPTION (pfile, no_output) = 1;
CPP_OPTION (pfile, inhibit_warnings) = 1;
break;
case OPT_MM:
CPP_OPTION (pfile, print_deps) = 1;
CPP_OPTION (pfile, no_output) = 1;
CPP_OPTION (pfile, inhibit_warnings) = 1;
break;
case OPT_MF:
CPP_OPTION (pfile, deps_file) = arg;
break;
case OPT_MP:
CPP_OPTION (pfile, deps_phony_targets) = 1;
break;
case OPT_MQ:
case OPT_MT:
/* Add a target. -MQ quotes for Make. */
deps_add_target (pfile->deps, arg, opt_code == OPT_MQ);
break;
case OPT_MD:
CPP_OPTION (pfile, print_deps) = 2;
CPP_OPTION (pfile, deps_file) = arg;
break;
case OPT_MMD:
CPP_OPTION (pfile, print_deps) = 1;
CPP_OPTION (pfile, deps_file) = arg;
break;
case OPT_A:
if (arg[0] == '-')
{
......@@ -1446,22 +1404,14 @@ cpp_handle_options (pfile, argc, argv)
return i;
}
/* Extra processing when all options are parsed, after all calls to
cpp_handle_option[s]. Consistency checks etc. */
void
cpp_post_options (pfile)
static void
post_options (pfile)
cpp_reader *pfile;
{
/* -Wtraditional is not useful in C++ mode. */
if (CPP_OPTION (pfile, cplusplus))
CPP_OPTION (pfile, warn_traditional) = 0;
/* The compiler front ends override this, but I think this is the
appropriate setting for the library. */
CPP_OPTION (pfile, warn_long_long)
= ((CPP_OPTION (pfile, pedantic) && !CPP_OPTION (pfile, c99))
|| CPP_OPTION (pfile, warn_traditional));
/* Permanently disable macro expansion if we are rescanning
preprocessed text. Read preprocesed source in ISO mode. */
if (CPP_OPTION (pfile, preprocessed))
......@@ -1473,18 +1423,4 @@ cpp_post_options (pfile)
/* Traditional CPP does not accurately track column information. */
if (CPP_OPTION (pfile, traditional))
CPP_OPTION (pfile, show_column) = 0;
/* -dM and dependencies suppress normal output; do it here so that
the last -d[MDN] switch overrides earlier ones. */
if (CPP_OPTION (pfile, dump_macros) == dump_only)
CPP_OPTION (pfile, no_output) = 1;
/* Disable -dD, -dN and -dI if normal output is suppressed. Allow
-dM since at least glibc relies on -M -dM to work. */
if (CPP_OPTION (pfile, no_output))
{
if (CPP_OPTION (pfile, dump_macros) != dump_only)
CPP_OPTION (pfile, dump_macros) = dump_none;
CPP_OPTION (pfile, dump_includes) = 0;
}
}
......@@ -227,10 +227,6 @@ struct cpp_options
/* Pending options - -D, -U, -A, -I, -ixxx. */
struct cpp_pending *pending;
/* File name which deps are being written to. This is 0 if deps are
being written to stdout. */
const char *deps_file;
/* Search paths for include files. */
struct search_path *quote_include; /* "" */
struct search_path *bracket_include; /* <> */
......@@ -276,21 +272,6 @@ struct cpp_options
/* Nonzero means to allow hexadecimal floats and LL suffixes. */
unsigned char extended_numbers;
/* Nonzero means print the names of included files rather than the
preprocessed output. 1 means just the #include "...", 2 means
#include <...> as well. */
unsigned char print_deps;
/* Nonzero if phony targets are created for each header. */
unsigned char deps_phony_targets;
/* Nonzero if missing .h files in -M output are assumed to be
generated files and not errors. */
unsigned char print_deps_missing_files;
/* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */
unsigned char print_deps_append;
/* Nonzero means print names of header files (-H). */
unsigned char print_include_names;
......@@ -394,6 +375,20 @@ struct cpp_options
/* True for traditional preprocessing. */
unsigned char traditional;
/* Dependency generation. */
struct
{
/* Style of header dependencies to generate. */
enum {DEPS_NONE = 0, DEPS_USER, DEPS_SYSTEM } style;
/* Assume missing files are generated files. */
bool missing_files;
/* Generate phony targets for each dependency apart from the first
one. */
bool phony_targets;
} deps;
/* Target-specific features set by the front end or client. */
/* Precision for target CPP arithmetic, target characters, target
......@@ -522,14 +517,10 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *));
/* Now call cpp_handle_option[s] to handle 1[or more] switches. The
return value is the number of arguments used. If
cpp_handle_options returns without using all arguments, it couldn't
understand the next switch. When there are no switches left, you
must call cpp_post_options before calling cpp_read_main_file. Only
after cpp_post_options are the contents of the cpp_options
structure reliable. Options processing is not completed until you
call cpp_finish_options. */
understand the next switch. Options processing is not completed
until you call cpp_finish_options. */
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
extern void cpp_post_options PARAMS ((cpp_reader *));
/* This function reads the file, but does not start preprocessing. It
returns the name of the original file; this is the same as the
......@@ -551,6 +542,13 @@ extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *,
from cpp_read_main_file, before they get debug callbacks. */
extern void cpp_finish_options PARAMS ((cpp_reader *));
/* Call this to finish preprocessing. If you requested dependency
generation, pass an open stream to write the information to,
otherwise NULL. It is your responsibility to close the stream.
Returns cpp_errors (pfile). */
extern int cpp_finish PARAMS ((cpp_reader *, FILE *deps_stream));
/* Call this to release the handle at the end of preprocessing. Any
use of the handle after this function returns is invalid. Returns
cpp_errors (pfile). */
......@@ -568,7 +566,6 @@ extern void cpp_register_pragma PARAMS ((cpp_reader *,
const char *, const char *,
void (*) PARAMS ((cpp_reader *))));
extern int cpp_finish PARAMS ((cpp_reader *, FILE *));
extern int cpp_avoid_paste PARAMS ((cpp_reader *, const cpp_token *,
const cpp_token *));
extern const cpp_token *cpp_get_token PARAMS ((cpp_reader *));
......
......@@ -632,7 +632,6 @@ read_scan_file (in_fname, argc, argv)
i = cpp_handle_options (scan_in, argc, argv);
if (i < argc)
cpp_error (scan_in, DL_ERROR, "invalid option `%s'", argv[i]);
cpp_post_options (scan_in);
if (cpp_errors (scan_in))
exit (FATAL_EXIT_CODE);
......
2002-08-13 Neil Booth <neil@daikokuya.co.uk>
* treelang.c: Remove cpp_post_options.
2002-08-08 Nathan Sidwell <nathan@codesourcery.com>
* treelang/Make-lang.in (treelang.mostlyclean): Remove coverage files.
......
......@@ -955,14 +955,6 @@ cpp_create_reader (enum c_lang lang ATTRIBUTE_UNUSED)
/* Should not be called for treelang. */
void
cpp_post_options (cpp_reader *pfile ATTRIBUTE_UNUSED)
{
abort ();
}
/* Should not be called for treelang. */
void
cpp_preprocess_file (cpp_reader *pfile ATTRIBUTE_UNUSED)
{
abort ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment