diff options
-rw-r--r-- | gcc/ChangeLog | 20 | ||||
-rw-r--r-- | gcc/ada/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/ada/misc.c | 14 | ||||
-rw-r--r-- | gcc/c-common.h | 4 | ||||
-rw-r--r-- | gcc/c-objc-common.c | 12 | ||||
-rw-r--r-- | gcc/c-opts.c | 57 | ||||
-rw-r--r-- | gcc/c-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/lex.c | 14 | ||||
-rw-r--r-- | gcc/f/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/f/com.c | 27 | ||||
-rw-r--r-- | gcc/java/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/java/lang.c | 136 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 5 | ||||
-rw-r--r-- | gcc/langhooks.c | 9 | ||||
-rw-r--r-- | gcc/langhooks.h | 25 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 12 | ||||
-rw-r--r-- | gcc/objc/objc-act.h | 2 | ||||
-rw-r--r-- | gcc/toplev.c | 31 | ||||
-rw-r--r-- | gcc/treelang/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/treelang/tree1.c | 24 | ||||
-rw-r--r-- | gcc/treelang/treelang.h | 2 | ||||
-rw-r--r-- | gcc/treelang/treetree.c | 42 | ||||
-rw-r--r-- | gcc/treelang/treetree.h | 18 |
25 files changed, 277 insertions, 212 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f8cacb7..ddaf7da 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2003-03-08 Neil Booth <neil@daikokuya.co.uk> + + * c-common.h (c_common_init, c_common_post_options): Update. + * c-objc-common.c (c_objc_common_init): Update for new prototype. + * c-opts.c (saved_lineno): New. + (c_common_post_options, c_common_init): Update prototypes, + move call to cpp_read_main_file from latter to former. + * c-tree.h (c_ojbc_common_init): Update. + * langhooks-def.h (lhd_post_options): New. + (LANG_HOOKS_INIT, LANG_HOOKS_POST_OPTIONS): Update. + * langhooks.c (lhd_post_options): New. + * langhooks.h (struct lang_hooks): Update post_options and init hooks. + * toplev.c (no_backend): New. + (process_options): Call post_options hook and set main_input_filename + and input_filename here. + (lang_dependent_init, do_compile): post_options hook moved to + process_options. + * objc/objc-act.c (objc_init): Update prototype. + * objc/objc-act.h (objc_init): Update prototype. + 2003-03-08 Roger Sayle <roger@eyesopen.com> * emit-rtl.c (gen_lowpart): Don't attempt to load a part of diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 009cd6e..e57e493 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,7 @@ +2003-03-08 Neil Booth <neil@daikokuya.co.uk> + + * misc.c (gnat_init): Update for new prototype. + 2003-03-05 Olivier Hainque <hainque@gnat.com> ada/9961 diff --git a/gcc/ada/misc.c b/gcc/ada/misc.c index a8293e7..1da50c3 100644 --- a/gcc/ada/misc.c +++ b/gcc/ada/misc.c @@ -79,7 +79,7 @@ extern FILE *asm_out_file; extern int save_argc; extern char **save_argv; -static const char *gnat_init PARAMS ((const char *)); +static bool gnat_init PARAMS ((void)); static void gnat_init_options PARAMS ((void)); static int gnat_decode_option PARAMS ((int, char **)); static HOST_WIDE_INT gnat_get_alias_set PARAMS ((tree)); @@ -337,9 +337,8 @@ internal_error_function (msgid, ap) /* Perform all the initialization steps that are language-specific. */ -static const char * -gnat_init (filename) - const char *filename; +static bool +gnat_init () { /* Performs whatever initialization steps needed by the language-dependent lexical analyzer. @@ -350,7 +349,7 @@ gnat_init (filename) gnat_init_decl_processing (); /* Add the input filename as the last argument. */ - gnat_argv[gnat_argc] = (char *) filename; + gnat_argv[gnat_argc] = (char *) main_input_filename; gnat_argc++; gnat_argv[gnat_argc] = 0; @@ -361,10 +360,7 @@ gnat_init (filename) set_lang_adjust_rli (gnat_adjust_rli); - if (filename == 0) - filename = ""; - - return filename; + return true; } /* If we are using the GCC mechanism for to process exception handling, we diff --git a/gcc/c-common.h b/gcc/c-common.h index 5214ef7..eb85e28 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -961,8 +961,8 @@ extern void disable_builtin_function PARAMS ((const char *)); extern tree build_va_arg PARAMS ((tree, tree)); extern void c_common_init_options PARAMS ((enum c_language_kind)); -extern bool c_common_post_options PARAMS ((void)); -extern const char *c_common_init PARAMS ((const char *)); +extern bool c_common_post_options PARAMS ((const char **)); +extern bool c_common_init PARAMS ((void)); extern void c_common_finish PARAMS ((void)); extern void c_common_parse_file PARAMS ((int)); extern HOST_WIDE_INT c_common_get_alias_set PARAMS ((tree)); diff --git a/gcc/c-objc-common.c b/gcc/c-objc-common.c index 4ef748c..e097527 100644 --- a/gcc/c-objc-common.c +++ b/gcc/c-objc-common.c @@ -241,15 +241,13 @@ c_warn_unused_global_decl (decl) } /* Initialization common to C and Objective-C front ends. */ -const char * -c_objc_common_init (filename) - const char *filename; +bool +c_objc_common_init () { c_init_decl_processing (); - filename = c_common_init (filename); - if (filename == NULL) - return NULL; + if (c_common_init () == false) + return false; lang_expand_decl_stmt = c_expand_decl_stmt; @@ -271,7 +269,7 @@ c_objc_common_init (filename) VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns"); - return filename; + return true; } /* Register a function tree, so that its optimization and conversion diff --git a/gcc/c-opts.c b/gcc/c-opts.c index ebf22d7..7f902ee9 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -39,6 +39,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA # define TARGET_SYSTEM_ROOT NULL #endif +static int saved_lineno; + /* CPP's options. */ static cpp_options *cpp_opts; @@ -1442,7 +1444,8 @@ c_common_decode_option (argc, argv) /* Post-switch processing. */ bool -c_common_post_options () +c_common_post_options (pfilename) + const char **pfilename; { /* Canonicalize the input and output filenames. */ if (in_fname == NULL || !strcmp (in_fname, "-")) @@ -1492,26 +1495,6 @@ c_common_post_options () if (warn_missing_format_attribute && !warn_format) warning ("-Wmissing-format-attribute ignored without -Wformat"); - /* If an error has occurred in cpplib, note it so we fail - immediately. */ - errorcount += cpp_errors (parse_in); - - return flag_preprocess_only; -} - -/* 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); - if (flag_preprocess_only) { /* Open the output now. We must do so even if flag_no_output is @@ -1539,19 +1522,43 @@ c_common_init (filename) } /* NOTE: we use in_fname here, not the one supplied. */ - filename = cpp_read_main_file (parse_in, in_fname, ident_hash); + *pfilename = cpp_read_main_file (parse_in, in_fname, ident_hash); + + saved_lineno = lineno; + lineno = 0; + + /* If an error has occurred in cpplib, note it so we fail + immediately. */ + errorcount += cpp_errors (parse_in); + + return flag_preprocess_only; +} + +/* Front end initialization common to C, ObjC and C++. */ +bool +c_common_init () +{ + lineno = saved_lineno; + + /* 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); if (flag_preprocess_only) { - if (filename) + if (main_input_filename) preprocess_file (parse_in); - return NULL; + return false; } /* Has to wait until now so that cpplib has its hash table. */ init_pragma (); - return filename; + return true; } /* Common finish hook for the C, ObjC and C++ front ends. */ diff --git a/gcc/c-tree.h b/gcc/c-tree.h index c698386..22d1ee2 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -245,7 +245,7 @@ extern tree make_pointer_declarator PARAMS ((tree, tree)); /* in c-objc-common.c */ extern int c_disregard_inline_limits PARAMS ((tree)); extern int c_cannot_inline_tree_fn PARAMS ((tree *)); -extern const char *c_objc_common_init PARAMS ((const char *)); +extern bool c_objc_common_init PARAMS ((void)); extern int c_missing_noreturn_ok_p PARAMS ((tree)); extern void c_objc_common_finish_file PARAMS ((void)); extern int defer_fn PARAMS ((tree)); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 53e1b74..fda3b80 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2003-03-08 Neil Booth <neil@daikokuya.co.uk> + + * cp-tree.h (cxx_init): Update prototype. + * lex.c (cxx_init): Similarly. + 2003-03-08 Mark Mitchell <mark@codesourcery.com> PR c++/9823 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index b4eeb76..6908291 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3964,7 +3964,7 @@ extern tree make_aggr_type (enum tree_code); extern void yyerror (const char *); extern void yyhook (int); extern int cp_type_qual_from_rid (tree); -extern const char *cxx_init (const char *); +extern bool cxx_init (void); extern void cxx_finish (void); extern void cxx_init_options (void); diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 774ed10..6433f2b 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -406,9 +406,8 @@ init_cp_pragma () the exact order that things are done here. It would be nice if the initialization done by this routine were moved to its subroutines, and the ordering dependencies clarified and reduced. */ -const char * -cxx_init (filename) - const char *filename; +bool +cxx_init (void) { input_filename = "<internal>"; @@ -446,15 +445,14 @@ cxx_init (filename) interface_unknown = 1; - filename = c_common_init (filename); - if (filename == NULL) - return NULL; + if (c_common_init () == false) + return false; init_cp_pragma (); - init_repo (filename); + init_repo (main_input_filename); - return filename; + return true; } /* Helper function to load global variables with interface diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index 9b08719..53216b8 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,8 @@ +Sat Mar 8 21:11:40 2003 Neil Booth <neil@daikokuya.co.uk> + + * com.c (ffe_init): Update prototype; move code to ffe_post_options. + (ffe_post_options): New. + 2003-03-04 Tom Tromey <tromey@redhat.com> * Make-lang.in (f77.tags): New target. diff --git a/gcc/f/com.c b/gcc/f/com.c index 4598b4f..9c71841 100644 --- a/gcc/f/com.c +++ b/gcc/f/com.c @@ -14030,8 +14030,9 @@ insert_block (tree block) } /* Each front end provides its own. */ -static const char *ffe_init PARAMS ((const char *)); +static bool ffe_init PARAMS ((void)); static void ffe_finish PARAMS ((void)); +static bool ffe_post_options PARAMS ((const char **)); static void ffe_init_options PARAMS ((void)); static void ffe_print_identifier PARAMS ((FILE *, tree, int)); @@ -14050,6 +14051,8 @@ struct language_function GTY(()) #define LANG_HOOKS_INIT_OPTIONS ffe_init_options #undef LANG_HOOKS_DECODE_OPTION #define LANG_HOOKS_DECODE_OPTION ffe_decode_option +#undef LANG_HOOKS_POST_OPTIONS +#define LANG_HOOKS_POST_OPTIONS ffe_post_options #undef LANG_HOOKS_PARSE_FILE #define LANG_HOOKS_PARSE_FILE ffe_parse_file #undef LANG_HOOKS_MARK_ADDRESSABLE @@ -14115,9 +14118,12 @@ const char *const tree_code_name[] = { }; #undef DEFTREECODE -static const char * -ffe_init (const char *filename) +static bool +ffe_post_options (pfilename) + const char **pfilename; { + const char *filename = *pfilename; + /* Open input file. */ if (filename == 0 || !strcmp (filename, "-")) { @@ -14126,9 +14132,17 @@ ffe_init (const char *filename) } else finput = fopen (filename, "r"); + if (finput == 0) fatal_io_error ("can't open %s", filename); + return false; +} + + +static bool +ffe_init () +{ #ifdef IO_BUFFER_SIZE setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); #endif @@ -14144,11 +14158,8 @@ ffe_init (const char *filename) ffelex_hash_kludge (finput); /* FIXME: The ffelex_hash_kludge code needs to be cleaned up to - return the new file name. */ - if (main_input_filename) - filename = main_input_filename; - - return filename; + set the new file name. Maybe in ffe_post_options. */ + return true; } static void diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index b65f0fc..163567c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2003-03-08 Neil Booth <neil@daikokuya.co.uk> + + * lang.c (java_init): Update prototype, move code to java_post_options. + (java_post_options): Similarly. + 2003-03-05 Ranjit Mathew <rmathew@hotmail.com> * jcf.h (COMPARE_FILENAMES): New macro similar to "strcmp" to diff --git a/gcc/java/lang.c b/gcc/java/lang.c index daa2e49..41441bf 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -53,10 +53,10 @@ struct string_option const int on_value; }; -static const char *java_init (const char *); +static bool java_init (void); static void java_finish (void); static void java_init_options (void); -static bool java_post_options (void); +static bool java_post_options (const char **); static int java_decode_option (int, char **); static void put_decl_string (const char *, int); @@ -508,8 +508,8 @@ java_decode_option (int argc __attribute__ ((__unused__)), char **argv) /* Global open file. */ FILE *finput; -static const char * -java_init (const char *filename) +static bool +java_init (void) { #if 0 extern int flag_minimal_debug; @@ -526,67 +526,6 @@ java_init (const char *filename) && force_align_functions_log < 1) force_align_functions_log = 1; - /* Open input file. */ - - if (filename == 0 || !strcmp (filename, "-")) - { - finput = stdin; - filename = "stdin"; - - if (dependency_tracking) - error ("can't do dependency tracking with input from stdin"); - } - else - { - if (dependency_tracking) - { - char *dot; - - /* If the target is set and the output filename is set, then - there's no processing to do here. Otherwise we must - compute one or the other. */ - if (! ((dependency_tracking & DEPEND_TARGET_SET) - && (dependency_tracking & DEPEND_FILE_ALREADY_SET))) - { - dot = strrchr (filename, '.'); - if (dot == NULL) - error ("couldn't determine target name for dependency tracking"); - else - { - char *buf = xmalloc (dot - filename + - 3 + sizeof (TARGET_OBJECT_SUFFIX)); - strncpy (buf, filename, dot - filename); - - /* If emitting class files, we might have multiple - targets. The class generation code takes care of - registering them. Otherwise we compute the - target name here. */ - if ((dependency_tracking & DEPEND_TARGET_SET)) - ; /* Nothing. */ - else if (flag_emit_class_files) - jcf_dependency_set_target (NULL); - else - { - strcpy (buf + (dot - filename), TARGET_OBJECT_SUFFIX); - jcf_dependency_set_target (buf); - } - - if ((dependency_tracking & DEPEND_FILE_ALREADY_SET)) - ; /* Nothing. */ - else if ((dependency_tracking & DEPEND_SET_FILE)) - { - strcpy (buf + (dot - filename), ".d"); - jcf_dependency_set_dep_file (buf); - } - else - jcf_dependency_set_dep_file ("-"); - - free (buf); - } - } - } - } - jcf_path_init (); jcf_path_seal (version_flag); @@ -594,7 +533,7 @@ java_init (const char *filename) using_eh_for_cleanups (); - return filename; + return true; } static void @@ -813,8 +752,10 @@ java_can_use_bit_fields_p (void) /* Post-switch processing. */ static bool -java_post_options (void) +java_post_options (const char **pfilename) { + const char *filename = *pfilename; + /* Use tree inlining if possible. Function instrumentation is only done in the RTL level, so we disable tree inlining. */ if (! flag_instrument_function_entry_exit) @@ -828,6 +769,67 @@ java_post_options (void) } } + /* Open input file. */ + + if (filename == 0 || !strcmp (filename, "-")) + { + finput = stdin; + filename = "stdin"; + + if (dependency_tracking) + error ("can't do dependency tracking with input from stdin"); + } + else + { + if (dependency_tracking) + { + char *dot; + + /* If the target is set and the output filename is set, then + there's no processing to do here. Otherwise we must + compute one or the other. */ + if (! ((dependency_tracking & DEPEND_TARGET_SET) + && (dependency_tracking & DEPEND_FILE_ALREADY_SET))) + { + dot = strrchr (filename, '.'); + if (dot == NULL) + error ("couldn't determine target name for dependency tracking"); + else + { + char *buf = xmalloc (dot - filename + + 3 + sizeof (TARGET_OBJECT_SUFFIX)); + strncpy (buf, filename, dot - filename); + + /* If emitting class files, we might have multiple + targets. The class generation code takes care of + registering them. Otherwise we compute the + target name here. */ + if ((dependency_tracking & DEPEND_TARGET_SET)) + ; /* Nothing. */ + else if (flag_emit_class_files) + jcf_dependency_set_target (NULL); + else + { + strcpy (buf + (dot - filename), TARGET_OBJECT_SUFFIX); + jcf_dependency_set_target (buf); + } + + if ((dependency_tracking & DEPEND_FILE_ALREADY_SET)) + ; /* Nothing. */ + else if ((dependency_tracking & DEPEND_SET_FILE)) + { + strcpy (buf + (dot - filename), ".d"); + jcf_dependency_set_dep_file (buf); + } + else + jcf_dependency_set_dep_file ("-"); + + free (buf); + } + } + } + } + /* Initialize the compiler back end. */ return false; } diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 8834e78..46ed062 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -46,6 +46,7 @@ extern void lhd_do_nothing_t PARAMS ((tree)); extern void lhd_do_nothing_i PARAMS ((int)); extern void lhd_do_nothing_f PARAMS ((struct function *)); extern int lhd_decode_option PARAMS ((int, char **)); +extern bool lhd_post_options PARAMS ((const char **)); extern HOST_WIDE_INT lhd_get_alias_set PARAMS ((tree)); extern tree lhd_return_tree PARAMS ((tree)); extern tree lhd_return_null_tree PARAMS ((tree)); @@ -86,13 +87,13 @@ void write_global_declarations PARAMS ((void)); #define LANG_HOOKS_NAME "GNU unknown" #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier) -#define LANG_HOOKS_INIT lhd_do_nothing +#define LANG_HOOKS_INIT hook_bool_void_false #define LANG_HOOKS_FINISH lhd_do_nothing #define LANG_HOOKS_PARSE_FILE lhd_do_nothing_i #define LANG_HOOKS_CLEAR_BINDING_STACK lhd_clear_binding_stack #define LANG_HOOKS_INIT_OPTIONS lhd_do_nothing #define LANG_HOOKS_DECODE_OPTION lhd_decode_option -#define LANG_HOOKS_POST_OPTIONS hook_bool_void_false +#define LANG_HOOKS_POST_OPTIONS lhd_post_options #define LANG_HOOKS_GET_ALIAS_SET lhd_get_alias_set #define LANG_HOOKS_EXPAND_CONSTANT lhd_return_tree #define LANG_HOOKS_EXPAND_EXPR lhd_expand_expr diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 7f5753dc..210cc23 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -93,6 +93,15 @@ lhd_decode_option (argc, argv) return 0; } +/* The default post options hook. */ + +bool +lhd_post_options (pfilename) + const char **pfilename ATTRIBUTE_UNUSED; +{ + return false; +} + /* Called from by print-tree.c. */ void diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 4e2685b..bf9826c 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -207,25 +207,20 @@ struct lang_hooks done for this option. */ int (*decode_option) PARAMS ((int, char **)); - /* Called when all command line options have been parsed. Should do - any required consistency checks, modifications etc. Complex - initialization should be left to the "init" callback, since GC - and the identifier hashes are set up between now and then. + /* Called when all command line options have been parsed to allow + further processing and initialization - Should return zero unless the compiler back-end does not need to - be initialized, such as with the -E option. + Should return true to indicate that a compiler back-end is + not required, such as with the -E option. If errorcount is nonzero after this call the compiler exits immediately and the finish hook is not called. */ - bool (*post_options) PARAMS ((void)); - - /* Called after post_options, to initialize the front end. The main - input filename is passed, which may be NULL; the front end should - return the original filename (e.g. foo.i -> foo.c). Return NULL - to indicate a serious error of some sort; in that case no - compilation is performed, and the finish hook is called - immediately. */ - const char * (*init) PARAMS ((const char *)); + bool (*post_options) PARAMS ((const char **)); + + /* Called after post_options to initialize the front end. Return + false to indicate that no further compilation be performed, in + which case the finish hook is called immediately. */ + bool (*init) PARAMS ((void)); /* Called at the end of compilation, as a finalizer. */ void (*finish) PARAMS ((void)); diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index c55f250..c23c622 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -432,13 +432,11 @@ generate_struct_by_value_array () exit (0); } -const char * -objc_init (filename) - const char *filename; +bool +objc_init () { - filename = c_objc_common_init (filename); - if (filename == NULL) - return filename; + if (c_objc_common_init () == false) + return false; /* Force the line number back to 0; check_newline will have raised it to 1, which will make the builtin functions appear @@ -482,7 +480,7 @@ objc_init (filename) if (print_struct_values) generate_struct_by_value_array (); - return filename; + return true; } void diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index c03e55a..c06c2b8 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -24,7 +24,7 @@ Boston, MA 02111-1307, USA. */ /*** Public Interface (procedures) ***/ -const char *objc_init PARAMS ((const char *)); +bool objc_init PARAMS ((void)); const char *objc_printable_name PARAMS ((tree, int)); /* used by yyparse */ diff --git a/gcc/toplev.c b/gcc/toplev.c index 9d6899d..7d7b346 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -104,7 +104,7 @@ extern void reg_alloc PARAMS ((void)); static void general_init PARAMS ((char *)); static void parse_options_and_default_flags PARAMS ((int, char **)); -static void do_compile PARAMS ((int)); +static void do_compile PARAMS ((void)); static void process_options PARAMS ((void)); static void backend_init PARAMS ((void)); static int lang_dependent_init PARAMS ((const char *)); @@ -135,6 +135,9 @@ static void print_switch_values PARAMS ((FILE *, int, int, const char *, /* Nonzero to dump debug info whilst parsing (-dy option). */ static int set_yydebug; +/* True if we don't need a backend (e.g. preprocessing only). */ +static bool no_backend; + /* Length of line when printing switch values. */ #define MAX_LINE 75 @@ -5169,6 +5172,13 @@ parse_options_and_default_flags (argc, argv) static void process_options () { + /* Allow the front end to perform consistency checks and do further + initialization based on the command line options. This hook also + sets the original filename if appropriate (e.g. foo.i -> foo.c) + so we can correctly initialize debug output. */ + no_backend = (*lang_hooks.post_options) (&filename); + main_input_filename = input_filename = filename; + #ifdef OVERRIDE_OPTIONS /* Some machines may reject certain combinations of options. */ OVERRIDE_OPTIONS; @@ -5411,15 +5421,10 @@ lang_dependent_init (name) if (dump_base_name == 0) dump_base_name = name ? name : "gccdump"; - /* Front-end initialization. This hook can assume that GC, - identifier hashes etc. are set up, but debug initialization is - not done yet. This routine must return the original filename - (e.g. foo.i -> foo.c) so can correctly initialize debug output. */ - name = (*lang_hooks.init) (name); - if (name == NULL) + /* Other front-end initialization. */ + if ((*lang_hooks.init) () == 0) return 0; - main_input_filename = input_filename = name; init_asm_output (name); /* These create various _DECL nodes, so need to be called after the @@ -5513,8 +5518,7 @@ finalize () /* Initialize the compiler, and compile the input file. */ static void -do_compile (no_backend) - int no_backend; +do_compile () { /* We cannot start timing until after options are processed since that says if we run timers or not. */ @@ -5558,16 +5562,11 @@ toplev_main (argc, argv) /* Exit early if we can (e.g. -help). */ if (!exit_after_options) { - /* All command line options have been parsed; allow the front - end to perform consistency checks, etc. */ - bool no_backend = (*lang_hooks.post_options) (); - - /* The bulk of command line switch processing. */ process_options (); /* Don't do any more if an error has already occurred. */ if (!errorcount) - do_compile (no_backend); + do_compile (); } if (errorcount || sorrycount) diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog index ed490c6..d727634 100644 --- a/gcc/treelang/ChangeLog +++ b/gcc/treelang/ChangeLog @@ -1,3 +1,15 @@ +2003-03-08 Neil Booth <neil@daikokuya.co.uk> + + * tree1.c (in_fname): Fix type. + (treelang_init): Update prototype and use of in_fname. + * treelang.h (in_fname): Fix type. + * treetree.c (tree_code_if_start, tree_code_if_else, + tree_code_if_end, tree_code_create_function_prototype, + tree_code_create_function_initial, tree_code_create_funciton_wrapup, + tree_code_create_variable, tree_code_output_expression_statement) + : Fix prototypes and use of filenames. + * treetree.h: Similarly. + 2003-03-05 Andreas Jaeger <aj@suse.de> * treetree.c (init_c_lex): Follow change to c-common.h. diff --git a/gcc/treelang/tree1.c b/gcc/treelang/tree1.c index 20913ba..e6f96d4 100644 --- a/gcc/treelang/tree1.c +++ b/gcc/treelang/tree1.c @@ -78,7 +78,7 @@ unsigned int option_lexer_trace = 0; /* Local variables. */ -unsigned char *in_fname = NULL; /* Input file name. */ +const char *in_fname; /* Input file name. */ /* This is 1 if we have output the version string. */ @@ -179,12 +179,12 @@ treelang_decode_option (num_options_left, first_option_left) /* Language dependent parser setup. */ -const char* -treelang_init (const char* filename) +bool +treelang_init () { - /* Set up the declarations needed for this front end. */ + in_fname = main_input_filename; - input_filename = ""; + /* Set up the declarations needed for this front end. */ lineno = 0; /* Init decls etc. */ @@ -193,7 +193,7 @@ treelang_init (const char* filename) /* This error will not happen from GCC as it will always create a fake input file. */ - if (!filename || (filename[0] == ' ') || (!filename[0])) + if (!in_fname || in_fname[0] == ' ' || !in_fname[0]) { if (!version_done) { @@ -201,17 +201,17 @@ treelang_init (const char* filename) exit (1); } - in_fname = NULL; - return NULL; + return false; } - yyin = fopen (filename, "r"); + + yyin = fopen (in_fname, "r"); if (!yyin) { - fprintf (stderr, "Unable to open input file %s\n", filename); + fprintf (stderr, "Unable to open input file %s\n", in_fname); exit (1); } - input_filename = filename; - return (char*) (in_fname = (unsigned char*)filename); + + return true; } /* Language dependent wrapup. */ diff --git a/gcc/treelang/treelang.h b/gcc/treelang/treelang.h index 6258c0e..5fded62 100644 --- a/gcc/treelang/treelang.h +++ b/gcc/treelang/treelang.h @@ -40,7 +40,7 @@ enum category_enum }; /* Input file name and FILE. */ -extern unsigned char* in_fname; +extern const char* in_fname; extern FILE* yyin; /* Forward references to satisfy mutually recursive definitions. */ diff --git a/gcc/treelang/treetree.c b/gcc/treelang/treetree.c index aedca9d..cc54559 100644 --- a/gcc/treelang/treetree.c +++ b/gcc/treelang/treetree.c @@ -179,14 +179,14 @@ tree_code_get_type (int type_num) LINENO in file FILENAME. */ void -tree_code_if_start (tree exp, unsigned char* filename, int lineno) +tree_code_if_start (tree exp, const char* filename, int lineno) { tree cond_exp; cond_exp = build (NE_EXPR, TREE_TYPE (exp), exp, build1 (CONVERT_EXPR, TREE_TYPE (exp), integer_zero_node)); - emit_line_note ((const char *)filename, lineno); /* Output the line number information. */ + emit_line_note (filename, lineno); /* Output the line number information. */ expand_start_cond (cond_exp, /* Exit-able if nonzero. */ 0); } @@ -194,9 +194,9 @@ tree_code_if_start (tree exp, unsigned char* filename, int lineno) at line LINENO in file FILENAME. */ void -tree_code_if_else (unsigned char* filename, int lineno) +tree_code_if_else (const char* filename, int lineno) { - emit_line_note ((const char *)filename, lineno); /* Output the line number information. */ + emit_line_note (filename, lineno); /* Output the line number information. */ expand_start_else (); } @@ -204,9 +204,9 @@ tree_code_if_else (unsigned char* filename, int lineno) at line LINENO in file FILENAME. */ void -tree_code_if_end (unsigned char* filename, int lineno) +tree_code_if_end (const char* filename, int lineno) { - emit_line_note ((const char *)filename, lineno); /* Output the line number information. */ + emit_line_note (filename, lineno); /* Output the line number information. */ expand_end_cond (); } @@ -219,7 +219,7 @@ tree_code_create_function_prototype (unsigned char* chars, unsigned int storage_class, unsigned int ret_type, struct prod_token_parm_item* parms, - unsigned char* filename, + const char* filename, int lineno) { @@ -252,7 +252,7 @@ tree_code_create_function_prototype (unsigned char* chars, fn_decl = build_decl (FUNCTION_DECL, id, fn_type); DECL_CONTEXT (fn_decl) = NULL_TREE; /* Nested functions not supported here. */ - DECL_SOURCE_FILE (fn_decl) = (const char *)filename; + DECL_SOURCE_FILE (fn_decl) = filename; /* if (lineno > 1000000) ; */ /* Probably the line # is rubbish because someone forgot to set the line number - and unfortunately impossible line #s are used as @@ -304,7 +304,7 @@ tree_code_create_function_prototype (unsigned char* chars, parameter details are in the lists PARMS. Returns nothing. */ void tree_code_create_function_initial (tree prev_saved, - unsigned char* filename, + const char* filename, int lineno, struct prod_token_parm_item* parms) { @@ -332,14 +332,14 @@ tree_code_create_function_initial (tree prev_saved, current_function_decl = fn_decl; DECL_INITIAL (fn_decl) = error_mark_node; - DECL_SOURCE_FILE (fn_decl) = (const char *)filename; + DECL_SOURCE_FILE (fn_decl) = filename; DECL_SOURCE_LINE (fn_decl) = lineno; /* Prepare creation of rtl for a new function. */ resultdecl = DECL_RESULT (fn_decl) = build_decl (RESULT_DECL, NULL_TREE, TREE_TYPE (TREE_TYPE (fn_decl))); DECL_CONTEXT (DECL_RESULT (fn_decl)) = fn_decl; - DECL_SOURCE_FILE (resultdecl) = (const char *)filename; + DECL_SOURCE_FILE (resultdecl) = filename; DECL_SOURCE_LINE (resultdecl) = lineno; /* Work out the size. ??? is this needed. */ layout_decl (DECL_RESULT (fn_decl), 0); @@ -359,7 +359,7 @@ tree_code_create_function_initial (tree prev_saved, if (!fn_decl) abort (); DECL_CONTEXT (parm_decl) = fn_decl; - DECL_SOURCE_FILE (parm_decl) = (const char *)filename; + DECL_SOURCE_FILE (parm_decl) = filename; DECL_SOURCE_LINE (parm_decl) = lineno; parm_list = chainon (parm_decl, parm_list); } @@ -389,7 +389,7 @@ tree_code_create_function_initial (tree prev_saved, make_decl_rtl (fn_decl, NULL); /* Use filename/lineno from above. */ - init_function_start (fn_decl, (const char *)filename, lineno); + init_function_start (fn_decl, filename, lineno); /* Create rtl for startup code of function, such as saving registers. */ @@ -435,12 +435,12 @@ tree_code_create_function_initial (tree prev_saved, expand_start_bindings (0); - emit_line_note ((const char *)filename, lineno); /* Output the line number information. */ + emit_line_note (filename, lineno); /* Output the line number information. */ } /* Wrapup a function contained in file FILENAME, ending at line LINENO. */ void -tree_code_create_function_wrapup (unsigned char* filename, +tree_code_create_function_wrapup (const char* filename, int lineno) { tree block; @@ -448,7 +448,7 @@ tree_code_create_function_wrapup (unsigned char* filename, fn_decl = current_function_decl; - emit_line_note ((const char *)filename, lineno); /* Output the line number information. */ + emit_line_note (filename, lineno); /* Output the line number information. */ /* Get completely built level from debugger symbol table. */ @@ -460,7 +460,7 @@ tree_code_create_function_wrapup (unsigned char* filename, /* Emit rtl for end of function. */ - expand_function_end ((const char *)filename, lineno, 0); + expand_function_end (filename, lineno, 0); /* Pop the level. */ @@ -498,7 +498,7 @@ tree_code_create_variable (unsigned int storage_class, unsigned int length, unsigned int expression_type, tree init, - unsigned char* filename, + const char* filename, int lineno) { tree var_type; @@ -531,7 +531,7 @@ tree_code_create_variable (unsigned int storage_class, DECL_CONTEXT (var_decl) = current_function_decl; - DECL_SOURCE_FILE (var_decl) = (const char *)filename; + DECL_SOURCE_FILE (var_decl) = filename; DECL_SOURCE_LINE (var_decl) = lineno; /* Set the storage mode and whether only visible in the same file. */ @@ -613,10 +613,10 @@ tree_code_generate_return (tree type, tree exp) void tree_code_output_expression_statement (tree code, - unsigned char* filename, int lineno) + const char* filename, int lineno) { /* Output the line number information. */ - emit_line_note ((const char *)filename, lineno); + emit_line_note (filename, lineno); TREE_USED (code) = 1; TREE_SIDE_EFFECTS (code) = 1; expand_expr_stmt (code); diff --git a/gcc/treelang/treetree.h b/gcc/treelang/treetree.h index 111cf12..c41dd6d 100644 --- a/gcc/treelang/treetree.h +++ b/gcc/treelang/treetree.h @@ -39,31 +39,31 @@ void tree_ggc_storage_always_used (void *m); tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1, tree op2, tree op3); tree tree_code_get_numeric_type (unsigned int size1, unsigned int sign1); void tree_code_create_function_initial (tree prev_saved, - unsigned char* filename, int lineno, + const char* filename, int lineno, struct prod_token_parm_item* parms); -void tree_code_create_function_wrapup (unsigned char* filename, int lineno); +void tree_code_create_function_wrapup (const char* filename, int lineno); tree tree_code_create_function_prototype (unsigned char* chars, unsigned int storage_class, unsigned int ret_type, struct prod_token_parm_item* parms, - unsigned char* filename, + const char* filename, int lineno); tree tree_code_create_variable (unsigned int storage_class, unsigned char* chars, unsigned int length, unsigned int expression_type, tree init, - unsigned char* filename, + const char* filename, int lineno); -void tree_code_output_expression_statement (tree code, unsigned char* filename, int lineno); +void tree_code_output_expression_statement (tree code, const char* filename, int lineno); tree get_type_for_numeric_type (unsigned int numeric_type); -void tree_code_if_start (tree exp, unsigned char* filename, int lineno); -void tree_code_if_else (unsigned char* filename, int lineno); -void tree_code_if_end (unsigned char* filename, int lineno); +void tree_code_if_start (tree exp, const char* filename, int lineno); +void tree_code_if_else (const char* filename, int lineno); +void tree_code_if_end (const char* filename, int lineno); tree tree_code_get_type (int type_num); void treelang_init_decl_processing (void); void treelang_finish (void); -const char *treelang_init (const char* filename); +bool treelang_init (void); int treelang_decode_option (int, char **); void treelang_parse_file (int debug_flag); void push_var_level (void); |