Commit 255c10b1 by Neil Booth Committed by Neil Booth

c-opts.c (finish_options): New.

	* c-opts.c (finish_options): New.
	(COMMAND_LINE_OPTIONS, c_common_decode_option): Add -imacros.
	(missing_arg): Handle OPT_include and OPT_imacros.
	(c_common_init, c_common_parse_file): Use finish_options.
	(handle_deferred_opts): Update.
	* cppinit.c (struct cpp_pending): Remove imacros_head and imacros_tail.
	(cpp_finish_options): Don't handle -imacros here.
	(no_fil): Remove.
	(COMMAND_LINE_OPTIONS, cpp_handle_option): Don't handle -imacros.

From-SVN: r64378
parent 027fbf43
2003-03-14 Neil Booth <neil@daikokuya.co.uk>
* c-opts.c (finish_options): New.
(COMMAND_LINE_OPTIONS, c_common_decode_option): Add -imacros.
(missing_arg): Handle OPT_include and OPT_imacros.
(c_common_init, c_common_parse_file): Use finish_options.
(handle_deferred_opts): Update.
* cppinit.c (struct cpp_pending): Remove imacros_head and imacros_tail.
(cpp_finish_options): Don't handle -imacros here.
(no_fil): Remove.
(COMMAND_LINE_OPTIONS, cpp_handle_option): Don't handle -imacros.
2003-03-14 Jakub Jelinek <jakub@redhat.com> 2003-03-14 Jakub Jelinek <jakub@redhat.com>
* config/rs6000/rs6000.c (rs6000_emit_load_toc_table): Don't call * config/rs6000/rs6000.c (rs6000_emit_load_toc_table): Don't call
......
...@@ -104,6 +104,7 @@ static void sanitize_cpp_opts PARAMS ((void)); ...@@ -104,6 +104,7 @@ static void sanitize_cpp_opts PARAMS ((void));
static void add_prefixed_path PARAMS ((const char *, size_t)); static void add_prefixed_path PARAMS ((const char *, size_t));
static void push_command_line_include PARAMS ((void)); static void push_command_line_include PARAMS ((void));
static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *)); static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
static void finish_options PARAMS ((void));
#ifndef STDC_0_IN_SYSTEM_HEADERS #ifndef STDC_0_IN_SYSTEM_HEADERS
#define STDC_0_IN_SYSTEM_HEADERS 0 #define STDC_0_IN_SYSTEM_HEADERS 0
...@@ -297,6 +298,7 @@ static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *)); ...@@ -297,6 +298,7 @@ static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
OPT("fxref", CL_CXX, OPT_fxref) \ OPT("fxref", CL_CXX, OPT_fxref) \
OPT("gen-decls", CL_OBJC, OPT_gen_decls) \ OPT("gen-decls", CL_OBJC, OPT_gen_decls) \
OPT("idirafter", CL_ALL | CL_ARG, OPT_idirafter) \ OPT("idirafter", CL_ALL | CL_ARG, OPT_idirafter) \
OPT("imacros", CL_ALL | CL_ARG, OPT_imacros) \
OPT("include", CL_ALL | CL_ARG, OPT_include) \ OPT("include", CL_ALL | CL_ARG, OPT_include) \
OPT("iprefix", CL_ALL | CL_ARG, OPT_iprefix) \ OPT("iprefix", CL_ALL | CL_ARG, OPT_iprefix) \
OPT("isysroot", CL_ALL | CL_ARG, OPT_isysroot) \ OPT("isysroot", CL_ALL | CL_ARG, OPT_isysroot) \
...@@ -421,6 +423,8 @@ missing_arg (opt_index) ...@@ -421,6 +423,8 @@ missing_arg (opt_index)
case OPT_MF: case OPT_MF:
case OPT_MD: case OPT_MD:
case OPT_MMD: case OPT_MMD:
case OPT_include:
case OPT_imacros:
case OPT_o: case OPT_o:
error ("missing filename after \"-%s\"", opt_text); error ("missing filename after \"-%s\"", opt_text);
break; break;
...@@ -1333,6 +1337,7 @@ c_common_decode_option (argc, argv) ...@@ -1333,6 +1337,7 @@ c_common_decode_option (argc, argv)
add_path (xstrdup (arg), AFTER, 0); add_path (xstrdup (arg), AFTER, 0);
break; break;
case OPT_imacros:
case OPT_include: case OPT_include:
defer_opt (code, arg); defer_opt (code, arg);
break; break;
...@@ -1566,8 +1571,7 @@ c_common_init () ...@@ -1566,8 +1571,7 @@ c_common_init ()
if (flag_preprocess_only) if (flag_preprocess_only)
{ {
cpp_finish_options (parse_in); finish_options ();
push_command_line_include ();
preprocess_file (parse_in); preprocess_file (parse_in);
return false; return false;
} }
...@@ -1593,8 +1597,7 @@ c_common_parse_file (set_yydebug) ...@@ -1593,8 +1597,7 @@ c_common_parse_file (set_yydebug)
#endif #endif
(*debug_hooks->start_source_file) (lineno, input_filename); (*debug_hooks->start_source_file) (lineno, input_filename);
cpp_finish_options (parse_in); finish_options();
push_command_line_include ();
pch_init(); pch_init();
yyparse (); yyparse ();
free_parser_stacks (); free_parser_stacks ();
...@@ -1694,6 +1697,7 @@ handle_deferred_opts () ...@@ -1694,6 +1697,7 @@ handle_deferred_opts ()
break; break;
case OPT_include: case OPT_include:
case OPT_imacros:
break; break;
default: default:
...@@ -1757,6 +1761,30 @@ add_prefixed_path (suffix, chain) ...@@ -1757,6 +1761,30 @@ add_prefixed_path (suffix, chain)
add_path (path, chain, 0); add_path (path, chain, 0);
} }
/* Handle -D, -U, -A, -imacros, and the first -include. */
static void
finish_options ()
{
cpp_finish_options (parse_in);
if (!cpp_opts->preprocessed)
{
unsigned int i;
/* Handle -imacros after -D, -U and -A. */
for (i = 0; i < deferred_count; i++)
{
struct deferred_opt *opt = &deferred_opts[i];
if (opt->code == OPT_imacros
&& cpp_push_include (parse_in, opt->arg))
cpp_scan_nooutput (parse_in);
}
}
push_command_line_include ();
}
/* Give CPP the next file given by -include, if any. */ /* Give CPP the next file given by -include, if any. */
static void static void
push_command_line_include () push_command_line_include ()
......
...@@ -47,7 +47,6 @@ struct pending_option ...@@ -47,7 +47,6 @@ struct pending_option
struct cpp_pending struct cpp_pending
{ {
struct pending_option *directive_head, *directive_tail; struct pending_option *directive_head, *directive_tail;
struct pending_option *imacros_head, *imacros_tail;
}; };
#ifdef __STDC__ #ifdef __STDC__
...@@ -606,16 +605,8 @@ cpp_finish_options (pfile) ...@@ -606,16 +605,8 @@ cpp_finish_options (pfile)
_cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0); _cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0);
for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next) for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next)
(*p->handler) (pfile, p->arg); (*p->handler) (pfile, p->arg);
/* Scan -imacros files after -D, -U, but before -include.
pfile->next_include_file is NULL, so _cpp_pop_buffer does not
push -include files. */
for (p = CPP_OPTION (pfile, pending)->imacros_head; p; p = p->next)
if (cpp_push_include (pfile, p->arg))
cpp_scan_nooutput (pfile);
} }
free_chain (CPP_OPTION (pfile, pending)->imacros_head);
free_chain (CPP_OPTION (pfile, pending)->directive_head); free_chain (CPP_OPTION (pfile, pending)->directive_head);
} }
...@@ -679,7 +670,6 @@ new_pending_directive (pend, text, handler) ...@@ -679,7 +670,6 @@ new_pending_directive (pend, text, handler)
I.e. a const string initializer with parens around it. That is I.e. a const string initializer with parens around it. That is
what N_("string") resolves to, so we make no_* be macros instead. */ what N_("string") resolves to, so we make no_* be macros instead. */
#define no_ass N_("assertion missing after %s") #define no_ass N_("assertion missing after %s")
#define no_fil N_("file name missing after %s")
#define no_mac N_("macro name missing after %s") #define no_mac N_("macro name missing after %s")
/* This is the list of all command line options, with the leading /* This is the list of all command line options, with the leading
...@@ -688,7 +678,6 @@ new_pending_directive (pend, text, handler) ...@@ -688,7 +678,6 @@ new_pending_directive (pend, text, handler)
DEF_OPT("A", no_ass, OPT_A) \ DEF_OPT("A", no_ass, OPT_A) \
DEF_OPT("D", no_mac, OPT_D) \ DEF_OPT("D", no_mac, OPT_D) \
DEF_OPT("U", no_mac, OPT_U) \ DEF_OPT("U", no_mac, OPT_U) \
DEF_OPT("imacros", no_fil, OPT_imacros) \
#define DEF_OPT(text, msg, code) code, #define DEF_OPT(text, msg, code) code,
...@@ -853,16 +842,6 @@ cpp_handle_option (pfile, argc, argv) ...@@ -853,16 +842,6 @@ cpp_handle_option (pfile, argc, argv)
case OPT_U: case OPT_U:
new_pending_directive (pend, arg, cpp_undef); new_pending_directive (pend, arg, cpp_undef);
break; break;
case OPT_imacros:
{
struct pending_option *o = (struct pending_option *)
xmalloc (sizeof (struct pending_option));
o->arg = arg;
o->next = NULL;
APPEND (pend, imacros, o);
}
break;
} }
} }
return i + 1; return i + 1;
......
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