Commit 96302433 by Neil Booth Committed by Neil Booth

c-lang.c (c_post_options): Call cpp_post_options.

        * c-lang.c (c_post_options): Call cpp_post_options.
        * cppmain.c (main): Similarly.
        * fix-header.c (read_scan_file): Similarly.
        * cp/decl2.c (cxx_post_options): Similarly.
        * objc/objc-act.c (objc_post_options): Similarly.
        * cppinit.c (cpp_start_read): Move option consistency checks
        to cpp_post_options.  Don't call init_dependency_output.
        If needed, add default target and main file dependency.
        (OPT_MD, OPT_MMD): Remove.
        (OPT_MF): New.
        (cpp_handle_option): Update for OPT_* changes.
        (cpp_post_options): New.
        (init_dependency_output): Command line -MF overrides environment
        variables.  Don't set default target etc.  Suppress output
        if dependencies are going to stdout.
        (print_help): Update.
        * cpplib.h (cpp_post_options): New.
        * gcc.c (cpp_options): Update for -MD, -MMD, -MF.

From-SVN: r38777
parent b34878a3
2001-01-07 Neil Booth <neil@daikokuya.demon.co.uk>
* c-lang.c (c_post_options): Call cpp_post_options.
* objc/objc-act.c (objc_post_options): Similarly.
* cppmain.c (main): Similarly.
* fix-header.c (read_scan_file): Similarly.
* cppinit.c (cpp_start_read): Move option consistency checks
to cpp_post_options. Don't call init_dependency_output.
If needed, add default target and main file dependency.
(OPT_MD, OPT_MMD): Remove.
(OPT_MF): New.
(cpp_handle_option): Update for OPT_* changes.
(cpp_post_options): New.
(init_dependency_output): Command line -MF overrides environment
variables. Don't set default target etc. Suppress output
if dependencies are going to stdout.
(print_help): Update.
* cpplib.h (cpp_post_options): New.
* gcc.c (cpp_options): Update for -MD, -MMD, -MF.
Sun Jan 7 14:44:19 MET 2001 Jan Hubicka <jh@suse.cz>
* jump.c (comparison_dominates_p): Support unordered compares.
......
......@@ -47,6 +47,7 @@ struct lang_hooks lang_hooks = {c_post_options};
static void
c_post_options ()
{
cpp_post_options (parse_in);
}
/* Each of the functions defined here
......
2001-01-07 Neil Booth <neil@daikokuya.demon.co.uk>
* cp/decl2.c (cxx_post_options): Call cpp_post_options.
2001-01-05 Nathan Sidwell <nathan@codesourcery.com>
* parse.y (template_datadef): Check for error_mark_node.
......
......@@ -551,6 +551,7 @@ struct lang_hooks lang_hooks = {cxx_post_options};
static void
cxx_post_options ()
{
cpp_post_options (parse_in);
}
/* Compare two option strings, pointed two by P1 and P2, for use with
......
......@@ -867,25 +867,6 @@ cpp_start_read (pfile, fname)
{
struct pending_option *p, *q;
/* -MG doesn't select the form of output and must be specified with one of
-M or -MM. -MG doesn't make sense with -MD or -MMD since they don't
inhibit compilation. */
if (CPP_OPTION (pfile, print_deps_missing_files)
&& (CPP_OPTION (pfile, print_deps) == 0
|| !CPP_OPTION (pfile, no_output)))
{
cpp_fatal (pfile, "-MG must be specified with one of -M or -MM");
return 0;
}
/* -Wtraditional is not useful in C++ mode. */
if (CPP_OPTION (pfile, cplusplus))
CPP_OPTION (pfile, warn_traditional) = 0;
/* Set this if it hasn't been set already. */
if (CPP_OPTION (pfile, user_label_prefix) == NULL)
CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
/* Set up the include search path now. */
if (! CPP_OPTION (pfile, no_standard_includes))
init_standard_includes (pfile);
......@@ -906,8 +887,6 @@ cpp_start_read (pfile, fname)
fprintf (stderr, _("End of search list.\n"));
}
/* Open the main input file. This must be done early, so we have a
buffer to stand on. */
if (CPP_OPTION (pfile, in_fname) == NULL
|| *CPP_OPTION (pfile, in_fname) == 0)
{
......@@ -918,11 +897,20 @@ cpp_start_read (pfile, fname)
if (CPP_OPTION (pfile, out_fname) == NULL)
CPP_OPTION (pfile, out_fname) = "";
if (CPP_OPTION (pfile, print_deps))
{
/* Set the default target (if there is none already). */
deps_add_default_target (pfile->deps, CPP_OPTION (pfile, in_fname));
if (CPP_OPTION (pfile, in_fname))
deps_add_dep (pfile->deps, CPP_OPTION (pfile, in_fname));
}
/* Open the main input file. This must be done early, so we have a
buffer to stand on. */
if (!_cpp_read_file (pfile, fname))
return 0;
init_dependency_output (pfile);
/* Install __LINE__, etc. */
init_builtins (pfile);
......@@ -1050,10 +1038,9 @@ new_pending_directive (pend, text, handler)
DEF_OPT("H", 0, OPT_H) \
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) \
......@@ -1448,43 +1435,22 @@ cpp_handle_option (pfile, argc, argv)
}
}
break;
/* The style of the choices here is a bit mixed.
The chosen scheme is a hybrid of keeping all options in one string
and specifying each option in a separate argument:
-M|-MM|-MD file|-MMD file [-MG]. An alternative is:
-M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
-M[M][G][D file]. This is awkward to handle in specs, and is not
as extensible. */
/* ??? -MG must be specified in addition to one of -M or -MM.
This can be relaxed in the future without breaking anything.
The converse isn't true. */
/* -MG isn't valid with -MD or -MMD. This is checked for later. */
case OPT_MG:
CPP_OPTION (pfile, print_deps_missing_files) = 1;
break;
case OPT_M:
case OPT_MD:
CPP_OPTION (pfile, print_deps) = 2;
break;
case OPT_MM:
case OPT_MMD:
if (opt_code == OPT_M || opt_code == OPT_MD)
CPP_OPTION (pfile, print_deps) = 2;
else
CPP_OPTION (pfile, print_deps) = 1;
/* For -MD and -MMD, write deps on file named by next arg. */
/* For -M and -MM, write deps on standard output and
suppress the usual output. */
if (opt_code == OPT_MD || opt_code == OPT_MMD)
CPP_OPTION (pfile, deps_file) = arg;
else
CPP_OPTION (pfile, no_output) = 1;
CPP_OPTION (pfile, print_deps) = 1;
break;
case OPT_MP:
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. */
......@@ -1680,9 +1646,37 @@ cpp_handle_options (pfile, argc, argv)
if (strings_processed == 0)
break;
}
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)
cpp_reader *pfile;
{
/* -Wtraditional is not useful in C++ mode. */
if (CPP_OPTION (pfile, cplusplus))
CPP_OPTION (pfile, warn_traditional) = 0;
/* Set this if it hasn't been set already. */
if (CPP_OPTION (pfile, user_label_prefix) == NULL)
CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
/* We need to do this after option processing and before
cpp_start_read, as cppmain.c relies on the options->no_output to
set its callbacks correctly before calling cpp_start_read. */
init_dependency_output (pfile);
/* -MG doesn't select the form of output and must be specified with
one of -M or -MM. -MG doesn't make sense unless preprocessed
output (and compilation) is inhibited. */
if (CPP_OPTION (pfile, print_deps_missing_files)
&& CPP_OPTION (pfile, print_deps) == 0)
cpp_fatal (pfile, "-MG must be specified with one of -M or -MM");
}
/* Set up dependency-file output. */
static void
init_dependency_output (pfile)
......@@ -1722,15 +1716,17 @@ init_dependency_output (pfile)
else
output_file = spec;
CPP_OPTION (pfile, deps_file) = output_file;
/* Command line overrides environment variables. */
if (CPP_OPTION (pfile, deps_file) == 0)
CPP_OPTION (pfile, deps_file) = output_file;
CPP_OPTION (pfile, print_deps_append) = 1;
}
/* Set the default target (if there is none already). */
deps_add_default_target (pfile->deps, CPP_OPTION (pfile, in_fname));
if (CPP_OPTION (pfile, in_fname))
deps_add_dep (pfile->deps, CPP_OPTION (pfile, in_fname));
/* If dependencies go to standard output, we need to suppress
output. The user may be requesting other stuff to stdout, with
-dM, -v etc. We let them shoot themselves in the foot. */
if (CPP_OPTION (pfile, deps_file) == 0)
CPP_OPTION (pfile, no_output) = 1;
}
static void
......@@ -1799,9 +1795,13 @@ Switches:\n\
fputs (_("\
-M Generate make dependencies\n\
-MM As -M, but ignore system header files\n\
-MD As -M, but put output in a .d file\n\
-MMD As -MD, but ignore system header files\n\
-MF <file> Write dependency output to the given file\n\
-MG Treat missing header file as generated files\n\
"), stdout);
fputs (_("\
-MP Generate phony targets for all headers\n\
-MQ <target> Add a MAKE-quoted target\n\
-MT <target> Add an unquoted target\n\
-g3 Include #define and #undef directives in the output\n\
"), stdout);
fputs (_("\
......
......@@ -704,14 +704,25 @@ struct cpp_hashnode
union tree_node *fe_value; /* Front end value. */
};
/* Call this first to get a handle to pass to other functions. */
extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
/* 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_start_read. Only
after cpp_post_options are the contents of the cpp_options
structure reliable. */
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 *));
extern unsigned int cpp_token_len PARAMS ((const cpp_token *));
extern unsigned char *cpp_token_as_text PARAMS ((cpp_reader *,
const cpp_token *));
extern unsigned char *cpp_spell_token PARAMS ((cpp_reader *, const cpp_token *,
unsigned char *));
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
extern void cpp_register_pragma PARAMS ((cpp_reader *,
const char *, const char *,
void (*) PARAMS ((cpp_reader *))));
......
......@@ -79,6 +79,7 @@ main (argc, argv)
argi += cpp_handle_options (pfile, argc - argi , argv + argi);
if (argi < argc && ! CPP_FATAL_ERRORS (pfile))
cpp_fatal (pfile, "Invalid option %s", argv[argi]);
cpp_post_options (pfile);
if (CPP_FATAL_ERRORS (pfile))
return (FATAL_EXIT_CODE);
......
......@@ -629,6 +629,7 @@ read_scan_file (in_fname, argc, argv)
i = cpp_handle_options (scan_in, argc, argv);
if (i < argc && ! CPP_FATAL_ERRORS (scan_in))
cpp_fatal (scan_in, "Invalid option `%s'", argv[i]);
cpp_post_options (pfile);
if (CPP_FATAL_ERRORS (scan_in))
exit (FATAL_EXIT_CODE);
......
......@@ -586,7 +586,7 @@ static const char *cpp_options =
"%{C:%{!E:%eGNU C does not support -C without using -E}}\
%{std*} %{nostdinc*}\
%{C} %{v} %{I*} %{P} %{$} %I\
%{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{MP} %{MQ} %{MT}\
%{M} %{MM} %{MD:-M -MF %b.d} %{MMD:-MM -MF %b.d} %{MF} %{MG} %{MP} %{MQ} %{MT}\
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
......
......@@ -634,6 +634,7 @@ struct lang_hooks lang_hooks = {objc_post_options};
static void
objc_post_options ()
{
cpp_post_options (parse_in);
}
/* Some platforms pass small structures through registers versus through
......
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