aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.co.uk>2003-03-14 23:47:24 +0000
committerNeil Booth <neil@gcc.gnu.org>2003-03-14 23:47:24 +0000
commit255c10b1a700c1d4d03f46384d0d905efdaf1294 (patch)
treeab378a1db5cdfc70cb85101af01a8e898f985515 /gcc
parent027fbf43fba633277bb6a7fa1dca7b70a8399ac2 (diff)
downloadgcc-255c10b1a700c1d4d03f46384d0d905efdaf1294.zip
gcc-255c10b1a700c1d4d03f46384d0d905efdaf1294.tar.gz
gcc-255c10b1a700c1d4d03f46384d0d905efdaf1294.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/c-opts.c36
-rw-r--r--gcc/cppinit.c21
3 files changed, 44 insertions, 25 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 646a4bd..d715d97 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+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>
* config/rs6000/rs6000.c (rs6000_emit_load_toc_table): Don't call
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index b931bbe..ce030e5 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -104,6 +104,7 @@ static void sanitize_cpp_opts PARAMS ((void));
static void add_prefixed_path PARAMS ((const char *, size_t));
static void push_command_line_include PARAMS ((void));
static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
+static void finish_options PARAMS ((void));
#ifndef STDC_0_IN_SYSTEM_HEADERS
#define STDC_0_IN_SYSTEM_HEADERS 0
@@ -297,6 +298,7 @@ static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
OPT("fxref", CL_CXX, OPT_fxref) \
OPT("gen-decls", CL_OBJC, OPT_gen_decls) \
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("iprefix", CL_ALL | CL_ARG, OPT_iprefix) \
OPT("isysroot", CL_ALL | CL_ARG, OPT_isysroot) \
@@ -421,6 +423,8 @@ missing_arg (opt_index)
case OPT_MF:
case OPT_MD:
case OPT_MMD:
+ case OPT_include:
+ case OPT_imacros:
case OPT_o:
error ("missing filename after \"-%s\"", opt_text);
break;
@@ -1333,6 +1337,7 @@ c_common_decode_option (argc, argv)
add_path (xstrdup (arg), AFTER, 0);
break;
+ case OPT_imacros:
case OPT_include:
defer_opt (code, arg);
break;
@@ -1566,8 +1571,7 @@ c_common_init ()
if (flag_preprocess_only)
{
- cpp_finish_options (parse_in);
- push_command_line_include ();
+ finish_options ();
preprocess_file (parse_in);
return false;
}
@@ -1593,8 +1597,7 @@ c_common_parse_file (set_yydebug)
#endif
(*debug_hooks->start_source_file) (lineno, input_filename);
- cpp_finish_options (parse_in);
- push_command_line_include ();
+ finish_options();
pch_init();
yyparse ();
free_parser_stacks ();
@@ -1694,6 +1697,7 @@ handle_deferred_opts ()
break;
case OPT_include:
+ case OPT_imacros:
break;
default:
@@ -1757,6 +1761,30 @@ add_prefixed_path (suffix, chain)
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. */
static void
push_command_line_include ()
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 6eeedf8..881b7e2 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -47,7 +47,6 @@ struct pending_option
struct cpp_pending
{
struct pending_option *directive_head, *directive_tail;
- struct pending_option *imacros_head, *imacros_tail;
};
#ifdef __STDC__
@@ -606,16 +605,8 @@ cpp_finish_options (pfile)
_cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0);
for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next)
(*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);
}
@@ -679,7 +670,6 @@ new_pending_directive (pend, text, handler)
I.e. a const string initializer with parens around it. That is
what N_("string") resolves to, so we make no_* be macros instead. */
#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")
/* This is the list of all command line options, with the leading
@@ -688,7 +678,6 @@ new_pending_directive (pend, text, handler)
DEF_OPT("A", no_ass, OPT_A) \
DEF_OPT("D", no_mac, OPT_D) \
DEF_OPT("U", no_mac, OPT_U) \
- DEF_OPT("imacros", no_fil, OPT_imacros) \
#define DEF_OPT(text, msg, code) code,
@@ -853,16 +842,6 @@ cpp_handle_option (pfile, argc, argv)
case OPT_U:
new_pending_directive (pend, arg, cpp_undef);
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;