From c1bad961ed99b234fb841ebca1832a0c98327714 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 15 Mar 2003 12:18:47 +0000 Subject: [PATCH] Makefile.in: Update. * Makefile.in: Update. * c-common.h (cb_register_builtins): Rename c_cpp_builtins. * c-lex.c (init_c_lex): Register builtins hook is dead. * c-opts.c (COMMAND_LINE_OPTIONS, missing_arg): Handle -A, -D and -U. (c_common_decode_option): Don't call cpp_handle_option. Handle -A, -D and -U. (handle_deferred_opts): Simplify. (finish_options): Define builtins and command line macros. * c-ppoutput.c (init_pp_output): Register builtins hook is dead. * cppinit.c: Don't include intl.h. (init_builtins): Rename cpp_init_builtins. No hook to call. (init_library): Don't need to sort options. (cpp_create_reader): Don't set pending. (cpp_destroy): Don't free pending. (struct pending_option, cl_directive_handler, struct cpp_pending, APPEND, free_chain, new_pending_directive, parse_option, opt_comp, cpp_finish_options, COMMAND_LINE_OPTIONS, DEF_OPT, struct cl_option, cl_options, cpp_handle_option): Remove. * cpplib.h (struct cpp_pending, register_builtins, cpp_handle_option, cpp_finish_options): Remove. (cpp_init_builtins): New. * fix-header.c (read_scan_file): Update to handle -D. Fix handling of -I. Replace call to cpp_finish_options. cp: * Make-lang.in: Update. From-SVN: r64398 --- gcc/ChangeLog | 26 +++++ gcc/Makefile.in | 10 +- gcc/c-common.h | 2 +- gcc/c-cppbuiltin.c | 2 +- gcc/c-lex.c | 1 - gcc/c-opts.c | 71 ++++++++---- gcc/c-ppoutput.c | 2 - gcc/cp/ChangeLog | 4 + gcc/cp/Make-lang.in | 2 +- gcc/cppinit.c | 314 +--------------------------------------------------- gcc/cpplib.h | 21 +--- gcc/fix-header.c | 37 +++++-- 12 files changed, 121 insertions(+), 371 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 206fffc..51da75e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,29 @@ +2003-03-15 Neil Booth + + * Makefile.in: Update. + * c-common.h (cb_register_builtins): Rename c_cpp_builtins. + * c-lex.c (init_c_lex): Register builtins hook is dead. + * c-opts.c (COMMAND_LINE_OPTIONS, missing_arg): Handle -A, -D and -U. + (c_common_decode_option): Don't call cpp_handle_option. + Handle -A, -D and -U. + (handle_deferred_opts): Simplify. + (finish_options): Define builtins and command line macros. + * c-ppoutput.c (init_pp_output): Register builtins hook is dead. + * cppinit.c: Don't include intl.h. + (init_builtins): Rename cpp_init_builtins. No hook to call. + (init_library): Don't need to sort options. + (cpp_create_reader): Don't set pending. + (cpp_destroy): Don't free pending. + (struct pending_option, cl_directive_handler, struct cpp_pending, + APPEND, free_chain, new_pending_directive, parse_option, opt_comp, + cpp_finish_options, COMMAND_LINE_OPTIONS, DEF_OPT, struct cl_option, + cl_options, cpp_handle_option): Remove. + * cpplib.h (struct cpp_pending, register_builtins, cpp_handle_option, + cpp_finish_options): Remove. + (cpp_init_builtins): New. + * fix-header.c (read_scan_file): Update to handle -D. Fix + handling of -I. Replace call to cpp_finish_options. + 2003-03-15 Michael Hayes PR optimization/9387 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index f1d5e91..6d088b0 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -789,7 +789,7 @@ CXX_TARGET_OBJS=@cxx_target_objs@ # Language-specific object files for C and Objective C. C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \ c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o \ - c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o \ + c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o \ c-objc-common.o c-dump.o c-pch.o libcpp.a $(C_TARGET_OBJS) # Language-specific object files for C. @@ -2315,7 +2315,7 @@ PREPROCESSOR_DEFINES = \ LIBCPP_OBJS = cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o cpptrad.o \ cpphash.o cpperror.o cppinit.o \ - hashtable.o line-map.o mkdeps.o prefix.o mbchar.o cpppch.o + hashtable.o line-map.o mkdeps.o mbchar.o cpppch.o LIBCPP_DEPS = $(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \ $(OBSTACK_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) @@ -2335,7 +2335,7 @@ cpplib.o: cpplib.c $(LIBCPP_DEPS) cpphash.o: cpphash.c $(LIBCPP_DEPS) cpptrad.o: cpptrad.c $(LIBCPP_DEPS) cppfiles.o: cppfiles.c $(LIBCPP_DEPS) $(SPLAY_TREE_H) mkdeps.h -cppinit.o: cppinit.c $(LIBCPP_DEPS) mkdeps.h prefix.h +cppinit.o: cppinit.c $(LIBCPP_DEPS) mkdeps.h cpppch.o: cpppch.c $(LIBCPP_DEPS) mkdeps.h cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ @@ -2553,9 +2553,9 @@ xsys-protos.h: $(GCC_PASSES) $(srcdir)/sys-protos.h deduced.h gen-protos$(build_ # This is nominally a 'build' program, but it's run only when host==build, # so we can (indeed, must) use $(LIBDEPS) and $(LIBS). fix-header$(build_exeext): fix-header.o scan-decls.o scan.o xsys-protos.h \ - c-incpath.o cppdefault.o $(LIBDEPS) libcpp.a + c-incpath.o cppdefault.o prefix.o $(LIBDEPS) libcpp.a $(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ fix-header.o \ - c-incpath.o cppdefault.o scan-decls.o scan.o libcpp.a $(LIBS) + c-incpath.o cppdefault.o scan-decls.o prefix.o scan.o libcpp.a $(LIBS) fix-header.o: fix-header.c $(OBSTACK_H) scan.h \ xsys-protos.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(CPPLIB_H) diff --git a/gcc/c-common.h b/gcc/c-common.h index 472cb50..b4a14a3 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -1263,7 +1263,7 @@ extern int c_common_unsafe_for_reeval PARAMS ((tree)); extern void init_c_lex PARAMS ((void)); -extern void cb_register_builtins PARAMS ((cpp_reader *)); +extern void c_cpp_builtins PARAMS ((cpp_reader *)); /* Positive if an implicit `extern "C"' scope has just been entered; negative if such a scope has just been exited. */ diff --git a/gcc/c-cppbuiltin.c b/gcc/c-cppbuiltin.c index a396b6b..060a7b1 100644 --- a/gcc/c-cppbuiltin.c +++ b/gcc/c-cppbuiltin.c @@ -281,7 +281,7 @@ define__GNUC__ () /* Hook that registers front end and target-specific built-ins. */ void -cb_register_builtins (pfile) +c_cpp_builtins (pfile) cpp_reader *pfile; { /* -undef turns off target-specific built-ins. */ diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 7256c5a..95419c5 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -112,7 +112,6 @@ init_c_lex () cb = cpp_get_callbacks (parse_in); - cb->register_builtins = cb_register_builtins; cb->line_change = cb_line_change; cb->ident = cb_ident; cb->def_pragma = cb_def_pragma; diff --git a/gcc/c-opts.c b/gcc/c-opts.c index ce030e5..adab26d7 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -149,8 +149,10 @@ static void finish_options PARAMS ((void)); #define COMMAND_LINE_OPTIONS \ OPT("-help", CL_ALL, OPT__help) \ OPT("-output-pch=", CL_ALL | CL_ARG, OPT__output_pch) \ + OPT("A", CL_ALL | CL_ARG, OPT_A) \ OPT("C", CL_ALL, OPT_C) \ OPT("CC", CL_ALL, OPT_CC) \ + OPT("D", CL_ALL | CL_ARG, OPT_D) \ OPT("E", CL_ALL, OPT_E) \ OPT("H", CL_ALL, OPT_H) \ OPT("I", CL_ALL | CL_ARG, OPT_I) \ @@ -164,6 +166,7 @@ static void finish_options PARAMS ((void)); OPT("MQ", CL_ALL | CL_ARG, OPT_MQ) \ OPT("MT", CL_ALL | CL_ARG, OPT_MT) \ OPT("P", CL_ALL, OPT_P) \ + OPT("U", CL_ALL | CL_ARG, OPT_U) \ OPT("Wabi", CL_CXX, OPT_Wabi) \ OPT("Wall", CL_ALL, OPT_Wall) \ OPT("Wbad-function-cast", CL_C, OPT_Wbad_function_cast) \ @@ -413,6 +416,15 @@ missing_arg (opt_index) error ("no class name specified with \"-%s\"", opt_text); break; + case OPT_A: + error ("assertion missing after \"-%s\"", opt_text); + break; + + case OPT_D: + case OPT_U: + error ("macro name missing after \"-%s\"", opt_text); + break; + case OPT_I: case OPT_idirafter: case OPT_isysroot: @@ -595,7 +607,7 @@ c_common_decode_option (argc, argv) const char *opt, *arg = 0; char *dup = 0; bool on = true; - int result, lang_flag; + int result = 0, lang_flag; const struct cl_option *option; enum opt_code code; @@ -632,8 +644,6 @@ c_common_decode_option (argc, argv) on = false; } - result = cpp_handle_option (parse_in, argc, argv); - /* Skip over '-'. */ lang_flag = lang_flags[(c_language << 1) + flag_objc]; opt_index = find_opt (opt + 1, lang_flag); @@ -694,6 +704,10 @@ c_common_decode_option (argc, argv) pch_file = arg; break; + case OPT_A: + defer_opt (code, arg); + break; + case OPT_C: cpp_opts->discard_comments = 0; break; @@ -703,6 +717,10 @@ c_common_decode_option (argc, argv) cpp_opts->discard_comments_in_macro_exp = 0; break; + case OPT_D: + defer_opt (code, arg); + break; + case OPT_E: flag_preprocess_only = 1; break; @@ -765,6 +783,10 @@ c_common_decode_option (argc, argv) flag_no_line_commands = 1; break; + case OPT_U: + defer_opt (code, arg); + break; + case OPT_Wabi: warn_abi = on; break; @@ -1689,20 +1711,8 @@ handle_deferred_opts () { struct deferred_opt *opt = &deferred_opts[i]; - switch (opt->code) - { - case OPT_MT: - case OPT_MQ: - cpp_add_dependency_target (parse_in, opt->arg, opt->code == OPT_MQ); - break; - - case OPT_include: - case OPT_imacros: - break; - - default: - abort (); - } + if (opt->code == OPT_MT || opt->code == OPT_MQ) + cpp_add_dependency_target (parse_in, opt->arg, opt->code == OPT_MQ); } } @@ -1765,13 +1775,32 @@ add_prefixed_path (suffix, chain) static void finish_options () { - cpp_finish_options (parse_in); - if (!cpp_opts->preprocessed) { - unsigned int i; + size_t i; + + cpp_rename_file (parse_in, _("")); + cpp_init_builtins (parse_in); + c_cpp_builtins (parse_in); + cpp_rename_file (parse_in, _("")); + for (i = 0; i < deferred_count; i++) + { + struct deferred_opt *opt = &deferred_opts[i]; + + if (opt->code == OPT_D) + cpp_define (parse_in, opt->arg); + else if (opt->code == OPT_U) + cpp_undef (parse_in, opt->arg); + else if (opt->code == OPT_A) + { + if (opt->arg[0] == '-') + cpp_unassert (parse_in, opt->arg + 1); + else + cpp_assert (parse_in, opt->arg); + } + } - /* Handle -imacros after -D, -U and -A. */ + /* Handle -imacros after -D and -U. */ for (i = 0; i < deferred_count; i++) { struct deferred_opt *opt = &deferred_opts[i]; diff --git a/gcc/c-ppoutput.c b/gcc/c-ppoutput.c index c4e3121..69eec22 100644 --- a/gcc/c-ppoutput.c +++ b/gcc/c-ppoutput.c @@ -95,8 +95,6 @@ init_pp_output (out_stream) { cpp_callbacks *cb = cpp_get_callbacks (parse_in); - cb->register_builtins = cb_register_builtins; - if (!flag_no_output) { cb->line_change = cb_line_change; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4635685..1fec2a5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2003-03-15 Neil Booth + + * Make-lang.in: Update. + 2003-03-15 Kriang Lerdsuwanakij PR c++/6440 diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 1659dc1..3f9695a 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -80,7 +80,7 @@ g++-cross$(exeext): g++$(exeext) # Shared with C front end: CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \ c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o c-pch.o \ - c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o + c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o # Language-specific object files. CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \ diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 881b7e2..abfcc50 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -25,53 +25,11 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "tm.h" #include "cpplib.h" #include "cpphash.h" -#include "intl.h" #include "mkdeps.h" -/* Internal structures and prototypes. */ - -/* A `struct pending_option' remembers one -D, -A, -U, -include, or - -imacros switch. */ -typedef void (* cl_directive_handler) PARAMS ((cpp_reader *, const char *)); -struct pending_option -{ - struct pending_option *next; - const char *arg; - cl_directive_handler handler; -}; - -/* The `pending' structure accumulates all the options that are not - actually processed until we hit cpp_read_main_file. It consists of - several lists, one for each type of option. We keep both head and - tail pointers for quick insertion. */ -struct cpp_pending -{ - struct pending_option *directive_head, *directive_tail; -}; - -#ifdef __STDC__ -#define APPEND(pend, list, elt) \ - do { if (!(pend)->list##_head) (pend)->list##_head = (elt); \ - else (pend)->list##_tail->next = (elt); \ - (pend)->list##_tail = (elt); \ - } while (0) -#else -#define APPEND(pend, list, elt) \ - do { if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \ - else (pend)->list/**/_tail->next = (elt); \ - (pend)->list/**/_tail = (elt); \ - } while (0) -#endif - static void init_library PARAMS ((void)); -static void init_builtins PARAMS ((cpp_reader *)); static void mark_named_operators PARAMS ((cpp_reader *)); -static void free_chain PARAMS ((struct pending_option *)); static void read_original_filename PARAMS ((cpp_reader *)); -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 *)); /* If we have designated initializers (GCC >2.7) these tables can be @@ -153,21 +111,7 @@ cpp_set_lang (pfile, lang) CPP_OPTION (pfile, digraphs) = l->digraphs; } -#ifdef HOST_EBCDIC -static int opt_comp PARAMS ((const void *, const void *)); - -/* Run-time sorting of options array. */ -static int -opt_comp (p1, p2) - const void *p1, *p2; -{ - return strcmp (((struct cl_option *) p1)->opt_text, - ((struct cl_option *) p2)->opt_text); -} -#endif - -/* init initializes library global state. It might not need to - do anything depending on the platform and compiler. */ +/* Initialize library global state. */ static void init_library () { @@ -177,12 +121,6 @@ init_library () { initialized = 1; -#ifdef HOST_EBCDIC - /* For non-ASCII hosts, the cl_options array needs to be sorted at - runtime. */ - qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp); -#endif - /* Set up the trigraph map. This doesn't need to do anything if we were compiled with a compiler that supports C99 designated initializers. */ @@ -216,9 +154,6 @@ cpp_create_reader (lang) CPP_OPTION (pfile, warn_deprecated) = 1; CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99); - CPP_OPTION (pfile, pending) = - (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending)); - /* Default CPP arithmetic to something sensible for the host for the benefit of dumb users like fix-header. */ CPP_OPTION (pfile, precision) = CHAR_BIT * sizeof (long); @@ -276,7 +211,6 @@ cpp_destroy (pfile) cpp_context *context, *contextn; tokenrun *run, *runn; - free (CPP_OPTION (pfile, pending)); free (pfile->op_stack); while (CPP_BUFFER (pfile) != NULL) @@ -391,10 +325,10 @@ mark_named_operators (pfile) } } -/* Subroutine of cpp_read_main_file; reads the builtins table above and - enters them, and language-specific macros, into the hash table. */ -static void -init_builtins (pfile) +/* Read the builtins table above and enter them, and language-specific + macros, into the hash table. */ +void +cpp_init_builtins (pfile) cpp_reader *pfile; { const struct builtin *b; @@ -422,24 +356,6 @@ init_builtins (pfile) if (CPP_OPTION (pfile, objc)) _cpp_define_builtin (pfile, "__OBJC__ 1"); - - if (pfile->cb.register_builtins) - (*pfile->cb.register_builtins) (pfile); -} - -/* Frees a pending_option chain. */ -static void -free_chain (head) - struct pending_option *head; -{ - struct pending_option *next; - - while (head) - { - next = head->next; - free (head); - head = next; - } } /* Sanity-checks are dependent on command-line options, so it is @@ -587,29 +503,6 @@ read_original_filename (pfile) _cpp_backup_tokens (pfile, 1); } -/* Handle pending command line options: -D, -U, -A, -imacros and - -include. This should be called after debugging has been properly - set up in the front ends. */ -void -cpp_finish_options (pfile) - cpp_reader *pfile; -{ - /* Install builtins and process command line macros etc. in the order - they appeared, but only if not already preprocessed. */ - if (! CPP_OPTION (pfile, preprocessed)) - { - struct pending_option *p; - - _cpp_do_file_change (pfile, LC_RENAME, _(""), 1, 0); - init_builtins (pfile); - _cpp_do_file_change (pfile, LC_RENAME, _(""), 1, 0); - for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next) - (*p->handler) (pfile, p->arg); - } - - free_chain (CPP_OPTION (pfile, pending)->directive_head); -} - /* This is called at the end of preprocessing. It pops the last buffer and writes dependency output, and returns the number of errors. @@ -650,203 +543,6 @@ cpp_finish (pfile, deps_stream) return pfile->errors; } -/* Add a directive to be handled later in the initialization phase. */ -static void -new_pending_directive (pend, text, handler) - struct cpp_pending *pend; - const char *text; - cl_directive_handler handler; -{ - struct pending_option *o = (struct pending_option *) - xmalloc (sizeof (struct pending_option)); - - o->arg = text; - o->next = NULL; - o->handler = handler; - APPEND (pend, directive, o); -} - -/* Irix6 "cc -n32" and OSF4 cc have problems with char foo[] = ("string"); - 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_mac N_("macro name missing after %s") - -/* This is the list of all command line options, with the leading - "-" removed. It must be sorted in ASCII collating order. */ -#define COMMAND_LINE_OPTIONS \ - DEF_OPT("A", no_ass, OPT_A) \ - DEF_OPT("D", no_mac, OPT_D) \ - DEF_OPT("U", no_mac, OPT_U) \ - - -#define DEF_OPT(text, msg, code) code, -enum opt_code -{ - COMMAND_LINE_OPTIONS - N_OPTS -}; -#undef DEF_OPT - -struct cl_option -{ - const char *opt_text; - const char *msg; - size_t opt_len; - enum opt_code opt_code; -}; - -#define DEF_OPT(text, msg, code) { text, msg, sizeof(text) - 1, code }, -#ifdef HOST_EBCDIC -static struct cl_option cl_options[] = -#else -static const struct cl_option cl_options[] = -#endif -{ - COMMAND_LINE_OPTIONS -}; -#undef DEF_OPT -#undef COMMAND_LINE_OPTIONS - -/* Perform a binary search to find which, if any, option the given - command-line matches. Returns its index in the option array, - negative on failure. Complications arise since some options can be - suffixed with an argument, and multiple complete matches can occur, - e.g. -pedantic and -pedantic-errors. */ -static int -parse_option (input) - const char *input; -{ - unsigned int md, mn, mx; - size_t opt_len; - int comp; - - mn = 0; - mx = N_OPTS; - - while (mx > mn) - { - md = (mn + mx) / 2; - - opt_len = cl_options[md].opt_len; - comp = strncmp (input, cl_options[md].opt_text, opt_len); - - if (comp > 0) - mn = md + 1; - else if (comp < 0) - mx = md; - else - { - if (input[opt_len] == '\0') - return md; - /* We were passed more text. If the option takes an argument, - we may match a later option or we may have been passed the - argument. The longest possible option match succeeds. - If the option takes no arguments we have not matched and - continue the search (e.g. input="stdc++" match was "stdc"). */ - mn = md + 1; - if (cl_options[md].msg) - { - /* Scan forwards. If we get an exact match, return it. - Otherwise, return the longest option-accepting match. - This loops no more than twice with current options. */ - mx = md; - for (; mn < (unsigned int) N_OPTS; mn++) - { - opt_len = cl_options[mn].opt_len; - if (strncmp (input, cl_options[mn].opt_text, opt_len)) - break; - if (input[opt_len] == '\0') - return mn; - if (cl_options[mn].msg) - mx = mn; - } - return mx; - } - } - } - - return -1; -} - -/* Handle one command-line option in (argc, argv). - Can be called multiple times, to handle multiple sets of options. - Returns number of strings consumed. */ -int -cpp_handle_option (pfile, argc, argv) - cpp_reader *pfile; - int argc; - char **argv; -{ - int i = 0; - struct cpp_pending *pend = CPP_OPTION (pfile, pending); - - { - enum opt_code opt_code; - int opt_index; - const char *arg = 0; - - /* Skip over '-'. */ - opt_index = parse_option (&argv[i][1]); - if (opt_index < 0) - return i; - - opt_code = cl_options[opt_index].opt_code; - if (cl_options[opt_index].msg) - { - arg = &argv[i][cl_options[opt_index].opt_len + 1]; - if (arg[0] == '\0') - { - arg = argv[++i]; - if (!arg) - { - cpp_error (pfile, DL_ERROR, - cl_options[opt_index].msg, argv[i - 1]); - return argc; - } - } - } - - switch (opt_code) - { - case N_OPTS: /* Shut GCC up. */ - break; - - case OPT_D: - new_pending_directive (pend, arg, cpp_define); - break; - - case OPT_A: - if (arg[0] == '-') - { - /* -A with an argument beginning with '-' acts as - #unassert on whatever immediately follows the '-'. - If "-" is the whole argument, we eliminate all - predefined macros and assertions, including those - that were specified earlier on the command line. - That way we can get rid of any that were passed - automatically in from GCC. */ - - if (arg[1] == '\0') - { - free_chain (pend->directive_head); - pend->directive_head = NULL; - pend->directive_tail = NULL; - } - else - new_pending_directive (pend, arg + 1, cpp_unassert); - } - else - new_pending_directive (pend, arg, cpp_assert); - break; - case OPT_U: - new_pending_directive (pend, arg, cpp_undef); - break; - } - } - return i + 1; -} - static void post_options (pfile) cpp_reader *pfile; diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 06a219c..7664b1f 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -213,9 +213,6 @@ struct cpp_options /* Characters between tab stops. */ unsigned int tabstop; - /* Pending options - -D, -U, -A, -I, -ixxx. */ - struct cpp_pending *pending; - /* Map between header names and file names, used only on DOS where file names are limited in length. */ struct file_name_map_list *map_list; @@ -380,9 +377,6 @@ struct cpp_callbacks void (*undef) PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *)); void (*ident) PARAMS ((cpp_reader *, unsigned int, const cpp_string *)); void (*def_pragma) PARAMS ((cpp_reader *, unsigned int)); - /* Called when the client has a chance to properly register - built-ins with cpp_define() and cpp_assert(). */ - void (*register_builtins) PARAMS ((cpp_reader *)); int (*valid_pch) PARAMS ((cpp_reader *, const char *, int)); void (*read_pch) PARAMS ((cpp_reader *, const char *, int, const char *)); }; @@ -517,11 +511,6 @@ extern const struct line_maps *cpp_get_line_maps PARAMS ((cpp_reader *)); extern cpp_callbacks *cpp_get_callbacks PARAMS ((cpp_reader *)); extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *)); -/* Now call cpp_handle_option to handle 1 switch. The return value is - the number of arguments used. Options processing is not completed - until you call cpp_finish_options. */ -extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **)); - /* This function reads the file, but does not start preprocessing. It returns the name of the original file; this is the same as the input file, except for preprocessed input. This will generate at @@ -535,12 +524,8 @@ extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **)); extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *, struct ht *)); -/* Deferred handling of command line options that can generate debug - callbacks, such as -D and -imacros. Call this after - cpp_read_main_file. The front ends need this separation so they - can initialize debug output with the original file name, returned - from cpp_read_main_file, before they get debug callbacks. */ -extern void cpp_finish_options PARAMS ((cpp_reader *)); +/* Set up built-ins like __FILE__. */ +extern void cpp_init_builtins PARAMS ((cpp_reader *)); /* Call this to finish preprocessing. If you requested dependency generation, pass an open stream to write the information to, @@ -578,7 +563,7 @@ extern cppchar_t cpp_interpret_charconst PARAMS ((cpp_reader *, const cpp_token *, unsigned int *, int *)); -/* Used to register builtins during the register_builtins callback. +/* Used to register macros and assertions, perhaps from the command line. The text is the same as the command line argument. */ extern void cpp_define PARAMS ((cpp_reader *, const char *)); extern void cpp_assert PARAMS ((cpp_reader *, const char *)); diff --git a/gcc/fix-header.c b/gcc/fix-header.c index 2bf4692..930728e 100644 --- a/gcc/fix-header.c +++ b/gcc/fix-header.c @@ -1,6 +1,6 @@ /* fix-header.c - Make C header file suitable for C++. Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2003 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -67,7 +67,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ * INFILE.H is a full pathname for the input file (e.g. /usr/include/stdio.h) * OUTFILE.H is the full pathname for where to write the output file, if anything needs to be done. (e.g. ./include/stdio.h) - * OPTIONS are such as you would pass to cpp. + * OPTIONS can be -D or -I switches as you would pass to cpp. Written by Per Bothner , July 1993. */ @@ -634,17 +634,28 @@ read_scan_file (in_fname, argc, argv) for (i = 0; i < argc; i += strings_processed) { - if (argv[i][0] == 'I') + strings_processed = 0; + if (argv[i][0] == '-') { - if (argv[i][1] != '\0') - strings_processed = 1, add_path (argv[i] + 1, BRACKET, false); - else if (i + 1 == argc) - strings_processed = 0; - else - strings_processed = 2, add_path (argv[i + 1], BRACKET, false); + if (argv[i][1] == 'I') + { + if (argv[i][2] != '\0') + strings_processed = 1, add_path (argv[i] + 2, BRACKET, false); + else if (i + 1 == argc) + strings_processed = 0; + else + strings_processed = 2, add_path (argv[i + 2], BRACKET, false); + } + else if (argv[i][1] == 'D') + { + if (argv[i][2] != '\0') + strings_processed = 1, cpp_define (scan_in, argv[i] + 2); + else if (i + 1 == argc) + strings_processed = 0; + else + strings_processed = 2, cpp_define (scan_in, argv[i + 1]); + } } - else - strings_processed = cpp_handle_option (scan_in, argc - i, argv + i); if (strings_processed == 0) break; @@ -661,7 +672,9 @@ read_scan_file (in_fname, argc, argv) if (! cpp_read_main_file (scan_in, in_fname, NULL)) exit (FATAL_EXIT_CODE); - cpp_finish_options (scan_in); + cpp_rename_file (scan_in, ""); + cpp_init_builtins (scan_in); + cpp_rename_file (scan_in, in_fname); /* We are scanning a system header, so mark it as such. */ cpp_make_system_header (scan_in, 1, 0); -- 2.7.4