c-common.c (STDC_0_IN_SYSTEM_HEADERS, [...]): Move to c-copts.c.

* c-common.c (STDC_0_IN_SYSTEM_HEADERS, c_common_init): Move
	to c-copts.c.
	(warn_multichar): Die.
	(cb_register_builtins): Export.
	* c-common.h (warn_multichar, preprocess_file): Remove.
	(cb_register_builtins): New.
	* c-lang.c (c_init): Remove.
	(LANG_HOOKS_INIT): Use c_objc_common_init.
	* c-lex.c (init_c_lex): Don't canonicalize filename.
	* c-opts.c (in_fname, STDC_0_IN_SYSTEM_HEADERS): New.
	(preprocess_file): Make static.  Update for cpplib.
	(c_common_decode_option): Remove warn_multichar.  Use in_fname.
	(c_common_post_options): Set some cpp options here.
	(c_common_init): Move from c-common.c.
	* cppinit.c (cpp_post_options): Don't canonicalize in_fname.
	* cpplib.h (struct cpp_options): Remove in_fname.
	(cpp_preprocess_file): Update.
	* cppmain.c (cpp_preprocess_file): Update for new prototypes.

From-SVN: r56223
This commit is contained in:
Neil Booth 2002-08-12 06:02:53 +00:00 committed by Neil Booth
parent f3f268dd79
commit 460bd0e32d
9 changed files with 88 additions and 93 deletions

View File

@ -1,3 +1,24 @@
2002-08-12 Neil Booth <neil@daikokuya.co.uk>
* c-common.c (STDC_0_IN_SYSTEM_HEADERS, c_common_init): Move
to c-copts.c.
(warn_multichar): Die.
(cb_register_builtins): Export.
* c-common.h (warn_multichar, preprocess_file): Remove.
(cb_register_builtins): New.
* c-lang.c (c_init): Remove.
(LANG_HOOKS_INIT): Use c_objc_common_init.
* c-lex.c (init_c_lex): Don't canonicalize filename.
* c-opts.c (in_fname, STDC_0_IN_SYSTEM_HEADERS): New.
(preprocess_file): Make static. Update for cpplib.
(c_common_decode_option): Remove warn_multichar. Use in_fname.
(c_common_post_options): Set some cpp options here.
(c_common_init): Move from c-common.c.
* cppinit.c (cpp_post_options): Don't canonicalize in_fname.
* cpplib.h (struct cpp_options): Remove in_fname.
(cpp_preprocess_file): Update.
* cppmain.c (cpp_preprocess_file): Update for new prototypes.
2002-08-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* config.gcc (mips*-*-netbsd*): Include ${tm_file}.

View File

@ -83,10 +83,6 @@ cpp_reader *parse_in; /* Declared in c-pragma.h. */
: "long long unsigned int"))
#endif
#ifndef STDC_0_IN_SYSTEM_HEADERS
#define STDC_0_IN_SYSTEM_HEADERS 0
#endif
#ifndef REGISTER_PREFIX
#define REGISTER_PREFIX ""
#endif
@ -310,10 +306,6 @@ int warn_conversion;
int warn_unknown_pragmas; /* Tri state variable. */
/* Nonzero means warn about use of multicharacter literals. */
int warn_multichar = 1;
/* Warn about format/argument anomalies in calls to formatted I/O functions
(*printf, *scanf, strftime, strfmon, etc.). */
@ -692,8 +684,6 @@ static int if_stack_space = 0;
/* Stack pointer. */
static int if_stack_pointer = 0;
static void cb_register_builtins PARAMS ((cpp_reader *));
static tree handle_packed_attribute PARAMS ((tree *, tree, tree, int,
bool *));
static tree handle_nocommon_attribute PARAMS ((tree *, tree, tree, int,
@ -4672,7 +4662,7 @@ boolean_increment (code, arg)
}
/* Hook that registers front end and target-specific built-ins. */
static void
void
cb_register_builtins (pfile)
cpp_reader *pfile;
{
@ -4884,52 +4874,6 @@ builtin_define_type_max (macro, type, is_long)
cpp_define (parse_in, buf);
}
/* Front end initialization common to C, ObjC and C++. */
const char *
c_common_init (filename)
const char *filename;
{
cpp_options *options = cpp_get_options (parse_in);
/* Set up preprocessor arithmetic. Must be done after call to
c_common_nodes_and_builtins for wchar_type_node to be good. */
options->precision = TYPE_PRECISION (intmax_type_node);
options->char_precision = TYPE_PRECISION (char_type_node);
options->int_precision = TYPE_PRECISION (integer_type_node);
options->wchar_precision = TYPE_PRECISION (wchar_type_node);
options->unsigned_wchar = TREE_UNSIGNED (wchar_type_node);
options->unsigned_char = !flag_signed_char;
options->warn_multichar = warn_multichar;
options->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
/* We want -Wno-long-long to override -pedantic -std=non-c99
and/or -Wtraditional, whatever the ordering. */
options->warn_long_long
= warn_long_long && ((!flag_isoc99 && pedantic) || warn_traditional);
/* Register preprocessor built-ins before calls to
cpp_main_file. */
cpp_get_callbacks (parse_in)->register_builtins = cb_register_builtins;
/* NULL is passed up to toplev.c and we exit quickly. */
if (flag_preprocess_only)
{
preprocess_file ();
return NULL;
}
/* Do this before initializing pragmas, as then cpplib's hash table
has been set up. */
filename = init_c_lex (filename);
init_pragma ();
if (!c_attrs_initialized)
c_init_attributes ();
return filename;
}
static void
c_init_attributes ()
{

View File

@ -481,10 +481,6 @@ extern int warn_conversion;
extern int warn_unknown_pragmas; /* Tri state variable. */
/* Nonzero means warn about use of multicharacter literals. */
extern int warn_multichar;
/* Warn about format/argument anomalies in calls to formatted I/O functions
(*printf, *scanf, strftime, strfmon, etc.). */
@ -1209,7 +1205,7 @@ extern int c_common_unsafe_for_reeval PARAMS ((tree));
extern const char *init_c_lex PARAMS ((const char *));
extern void preprocess_file PARAMS ((void));
extern void cb_register_builtins PARAMS ((cpp_reader *));
/* Information recorded about each file examined during compilation. */

View File

@ -29,7 +29,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "langhooks.h"
#include "langhooks-def.h"
static const char *c_init PARAMS ((const char *));
static void c_init_options PARAMS ((void));
/* ### When changing hooks, consider if ObjC needs changing too!! ### */
@ -37,7 +36,7 @@ static void c_init_options PARAMS ((void));
#undef LANG_HOOKS_NAME
#define LANG_HOOKS_NAME "GNU C"
#undef LANG_HOOKS_INIT
#define LANG_HOOKS_INIT c_init
#define LANG_HOOKS_INIT c_objc_common_init
#undef LANG_HOOKS_FINISH
#define LANG_HOOKS_FINISH c_common_finish
#undef LANG_HOOKS_INIT_OPTIONS
@ -159,13 +158,6 @@ c_init_options ()
c_common_init_options (clk_c);
}
static const char *
c_init (filename)
const char *filename;
{
return c_objc_common_init (filename);
}
/* Used by c-lex.c, but only for objc. */
tree

View File

@ -135,9 +135,6 @@ init_c_lex (filename)
/* Start it at 0. */
lineno = 0;
if (filename == NULL || !strcmp (filename, "-"))
filename = "";
return cpp_read_main_file (parse_in, filename, ident_hash);
}

View File

@ -33,6 +33,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
static cpp_options *cpp_opts;
/* Input filename. */
static const char *in_fname;
/* Filename and stream for preprocessed output. */
static const char *out_fname;
static FILE *out_stream;
@ -51,6 +54,11 @@ static void set_std_cxx98 PARAMS ((int));
static void set_std_c89 PARAMS ((int, int));
static void set_std_c99 PARAMS ((int));
static void check_deps_environment_vars PARAMS ((void));
static void preprocess_file PARAMS ((void));
#ifndef STDC_0_IN_SYSTEM_HEADERS
#define STDC_0_IN_SYSTEM_HEADERS 0
#endif
#define CL_C_ONLY (1 << 0) /* Only C. */
#define CL_OBJC_ONLY (1 << 1) /* Only ObjC. */
@ -462,8 +470,8 @@ c_common_decode_option (argc, argv)
/* Interpret "-" or a non-switch as a file name. */
if (opt[0] != '-' || opt[1] == '\0')
{
if (!cpp_opts->in_fname)
cpp_opts->in_fname = opt;
if (!in_fname)
in_fname = opt;
else if (!out_fname)
out_fname = opt;
else
@ -565,7 +573,6 @@ c_common_decode_option (argc, argv)
set_Wimplicit (on);
warn_char_subscripts = on;
warn_missing_braces = on;
warn_multichar = on; /* Was C++ only. */
warn_parentheses = on;
warn_return_type = on;
warn_sequence_point = on; /* Was C only. */
@ -598,6 +605,7 @@ c_common_decode_option (argc, argv)
cpp_opts->warn_trigraphs = on;
cpp_opts->warn_comments = on;
cpp_opts->warn_num_sign_change = on;
cpp_opts->warn_multichar = on; /* Was C++ only. */
break;
case OPT_Wbad_function_cast:
@ -728,7 +736,7 @@ c_common_decode_option (argc, argv)
break;
case OPT_Wmultichar:
warn_multichar = on;
cpp_opts->warn_multichar = on;
break;
case OPT_Wnested_externs:
@ -1204,7 +1212,10 @@ c_common_decode_option (argc, argv)
bool
c_common_post_options ()
{
/* Canonicalize the output filename. */
/* Canonicalize the input and output filenames. */
if (in_fname == NULL || !strcmp (in_fname, "-"))
in_fname = "";
if (out_fname == NULL || !strcmp (out_fname, "-"))
out_fname = "";
@ -1221,6 +1232,14 @@ c_common_post_options ()
cpp_post_options (parse_in);
cpp_opts->unsigned_char = !flag_signed_char;
cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
/* We want -Wno-long-long to override -pedantic -std=non-c99
and/or -Wtraditional, whatever the ordering. */
cpp_opts->warn_long_long
= warn_long_long && ((!flag_isoc99 && pedantic) || warn_traditional);
flag_inline_trees = 1;
/* Use tree inlining if possible. Function instrumentation is only
@ -1263,7 +1282,7 @@ c_common_post_options ()
}
/* Preprocess the input file to out_stream. */
void
static void
preprocess_file ()
{
/* Open the output now. We must do so even if no_output is on,
@ -1277,7 +1296,41 @@ preprocess_file ()
if (out_stream == NULL)
fatal_io_error ("opening output file %s", out_fname);
else
cpp_preprocess_file (parse_in, out_stream);
cpp_preprocess_file (parse_in, in_fname, out_stream);
}
/* Front end initialization common to C, ObjC and C++. */
const char *
c_common_init (filename)
const char *filename;
{
/* Set up preprocessor arithmetic. Must be done after call to
c_common_nodes_and_builtins for type nodes to be good. */
cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
cpp_opts->unsigned_wchar = TREE_UNSIGNED (wchar_type_node);
/* Register preprocessor built-ins before calls to
cpp_main_file. */
cpp_get_callbacks (parse_in)->register_builtins = cb_register_builtins;
/* NULL is passed up to toplev.c and we exit quickly. */
if (flag_preprocess_only)
{
preprocess_file ();
return NULL;
}
/* Do this before initializing pragmas, as then cpplib's hash table
has been set up. NOTE: we are using our own file name here, not
the one supplied. */
filename = init_c_lex (in_fname);
init_pragma ();
return filename;
}
/* Common finish hook for the C, ObjC and C++ front ends. */

View File

@ -1452,12 +1452,6 @@ void
cpp_post_options (pfile)
cpp_reader *pfile;
{
/* Canonicalize in_fname and out_fname. We guarantee they are not
NULL, and that the empty string represents stdin / stdout. */
if (CPP_OPTION (pfile, in_fname) == NULL
|| !strcmp (CPP_OPTION (pfile, in_fname), "-"))
CPP_OPTION (pfile, in_fname) = "";
/* -Wtraditional is not useful in C++ mode. */
if (CPP_OPTION (pfile, cplusplus))
CPP_OPTION (pfile, warn_traditional) = 0;

View File

@ -221,9 +221,6 @@ enum { dump_none = 0, dump_only, dump_names, dump_definitions };
carries all the options visible to the command line. */
struct cpp_options
{
/* Name of input and output files. */
const char *in_fname;
/* Characters between tab stops. */
unsigned int tabstop;
@ -726,7 +723,7 @@ extern int cpp_included PARAMS ((cpp_reader *, const char *));
extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int));
/* In cppmain.c */
extern void cpp_preprocess_file PARAMS ((cpp_reader *, FILE *));
extern void cpp_preprocess_file PARAMS ((cpp_reader *, const char *, FILE *));
#ifdef __cplusplus
}

View File

@ -67,8 +67,9 @@ static struct printer print;
/* Preprocess and output. */
void
cpp_preprocess_file (pfile, out_stream)
cpp_preprocess_file (pfile, in_fname, out_stream)
cpp_reader *pfile;
const char *in_fname;
FILE *out_stream;
{
options = cpp_get_options (pfile);
@ -84,7 +85,7 @@ cpp_preprocess_file (pfile, out_stream)
setup_callbacks (pfile);
if (cpp_read_main_file (pfile, options->in_fname, NULL))
if (cpp_read_main_file (pfile, in_fname, NULL))
{
cpp_finish_options (pfile);