From 7fb26bb00173af1f41d3df4b5a7a43be9e3f12db Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Wed, 11 Jun 2003 22:21:10 +0000 Subject: [PATCH] hooks.c (hook_int_size_t_constcharptr_int_0): New. * hooks.c (hook_int_size_t_constcharptr_int_0): New. * hooks.h (hook_int_size_t_constcharptr_int_0): New. * langhooks-def.h (lhd_decode_option, LANG_HOOKS_DECODE_OPTION): Die. (LANG_HOOKS_HANDLE_OPTION, LANG_HOOKS_INITIALIZER): Update. * langhooks.c (lhd_decode_option): Remove. * langhooks.h (struct lang_hooks): Remove decode_option. * opts.c (handle_option): No longer use decode_option. java: * Make-lang.in: Handle mostlyclean. treelang: * Make-lang.in: Update for option handling. * lang.opt: New. * tree1.c: Include opts.h and t-options.h. (treelang_decode_option): Remove. (treelang_handle_option): New. * treetree.c (LANG_HOOKS_DECODE_OPTION): Remove. (LANG_HOOKS_HANDLE_OPTION): Override. * treetree.h (treelang_decode_option): Remove. (treelang_handle_option): New. From-SVN: r67799 --- gcc/ChangeLog | 10 ++++ gcc/hooks.c | 8 +++ gcc/hooks.h | 1 + gcc/java/ChangeLog | 4 ++ gcc/java/Make-lang.in | 1 + gcc/langhooks-def.h | 9 +-- gcc/langhooks.c | 10 ---- gcc/langhooks.h | 10 ---- gcc/opts.c | 6 +- gcc/treelang/ChangeLog | 12 ++++ gcc/treelang/Make-lang.in | 14 ++++- gcc/treelang/lang.opt | 59 ++++++++++++++++++++ gcc/treelang/tree1.c | 112 ++++++++++++-------------------------- gcc/treelang/treetree.c | 4 +- gcc/treelang/treetree.h | 2 +- 15 files changed, 147 insertions(+), 115 deletions(-) create mode 100644 gcc/treelang/lang.opt diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 018bb83a3f5c..cf8050db53d2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2003-06-11 Neil Booth + + * hooks.c (hook_int_size_t_constcharptr_int_0): New. + * hooks.h (hook_int_size_t_constcharptr_int_0): New. + * langhooks-def.h (lhd_decode_option, LANG_HOOKS_DECODE_OPTION): Die. + (LANG_HOOKS_HANDLE_OPTION, LANG_HOOKS_INITIALIZER): Update. + * langhooks.c (lhd_decode_option): Remove. + * langhooks.h (struct lang_hooks): Remove decode_option. + * opts.c (handle_option): No longer use decode_option. + 2003-06-11 Zdenek Dvorak * cfgloopanal.c (variable_initial_value): Update the set of altered diff --git a/gcc/hooks.c b/gcc/hooks.c index a80ded7fc41d..438af66f921c 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -110,6 +110,14 @@ hook_int_void_0 (void) return 0; } +int +hook_int_size_t_constcharptr_int_0 (size_t a ATTRIBUTE_UNUSED, + const char *b ATTRIBUTE_UNUSED, + int c ATTRIBUTE_UNUSED) +{ + return 0; +} + void hook_void_tree (a) tree a ATTRIBUTE_UNUSED; diff --git a/gcc/hooks.h b/gcc/hooks.h index 407440fe3318..15b742da1783 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -40,6 +40,7 @@ void hook_void_tree_treeptr PARAMS ((tree, tree *)); int hook_int_tree_tree_1 PARAMS ((tree, tree)); int hook_int_rtx_0 PARAMS ((rtx)); int hook_int_void_0 (void); +int hook_int_size_t_constcharptr_int_0 (size_t, const char *, int); bool default_can_output_mi_thunk_no_vcall PARAMS ((tree, HOST_WIDE_INT, HOST_WIDE_INT, tree)); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 9d4f9b5e5dc7..fcd451d53624 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,7 @@ +2003-06-11 Neil Booth + + * Make-lang.in: Handle mostlyclean. + 2003-06-11 Tom Tromey * lang.c (java_handle_option): Update dependency_tracking for diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in index a4356d7f79b7..7bac18726491 100644 --- a/gcc/java/Make-lang.in +++ b/gcc/java/Make-lang.in @@ -237,6 +237,7 @@ java.install-info: installdirs java.mostlyclean: -rm -f java/*$(objext) $(DEMANGLER_PROG) -rm -f java/*$(coverageexts) + -rm -f java/j-options.c java/j-options.h -rm -f jc1$(exeext) $(GCJ)$(exeext) jvgenmain$(exeext) gcjh$(exeext) jv-scan$(exeext) jcf-dump$(exeext) s-java java.clean: java.distclean: diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 8e6f8424c8af..a7f0abcd39f8 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -35,9 +35,7 @@ extern HOST_WIDE_INT hook_get_alias_set_0 PARAMS ((tree)); The macros in this file should NOT be surrounded by a #ifdef...#endif pair, since this file declares the defaults. Each front end overrides any hooks it wishes to, in the file containing - its struct lang_hooks, AFTER including this file. - - Prefix all default hooks with "lhd_". */ + its struct lang_hooks, AFTER including this file. */ /* See langhooks.h for the definition and documentation of each hook. */ @@ -45,7 +43,6 @@ extern void lhd_do_nothing PARAMS ((void)); 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)); @@ -94,8 +91,7 @@ void write_global_declarations PARAMS ((void)); #define LANG_HOOKS_PARSE_FILE lhd_do_nothing_i #define LANG_HOOKS_CLEAR_BINDING_STACK lhd_clear_binding_stack #define LANG_HOOKS_INIT_OPTIONS hook_int_void_0 -#define LANG_HOOKS_DECODE_OPTION lhd_decode_option -#define LANG_HOOKS_HANDLE_OPTION NULL +#define LANG_HOOKS_HANDLE_OPTION hook_int_size_t_constharptr_int_0 #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 @@ -246,7 +242,6 @@ int lhd_tree_dump_type_quals PARAMS ((tree)); LANG_HOOKS_IDENTIFIER_SIZE, \ LANG_HOOKS_TREE_SIZE, \ LANG_HOOKS_INIT_OPTIONS, \ - LANG_HOOKS_DECODE_OPTION, \ LANG_HOOKS_HANDLE_OPTION, \ LANG_HOOKS_POST_OPTIONS, \ LANG_HOOKS_INIT, \ diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 2bc91481eee5..423bb5f421b2 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -83,16 +83,6 @@ lhd_return_null_tree (t) return NULL_TREE; } -/* Do nothing; the default hook to decode an option. */ - -int -lhd_decode_option (argc, argv) - int argc ATTRIBUTE_UNUSED; - char **argv ATTRIBUTE_UNUSED; -{ - return 0; -} - /* The default post options hook. */ bool diff --git a/gcc/langhooks.h b/gcc/langhooks.h index fb648bf51ae7..cfb26de59949 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -206,16 +206,6 @@ struct lang_hooks the language mask to filter the switch array with. */ int (*init_options) PARAMS ((void)); - /* Function called with an option vector as argument, to decode a - single option (typically starting with -f or -W or +). It should - return the number of command-line arguments it uses if it handles - the option, or 0 and not complain if it does not recognize the - option. If this function returns a negative number, then its - absolute value is the number of command-line arguments used, but, - in addition, no language-independent option processing should be - done for this option. Obsoleted by handle_option. */ - int (*decode_option) PARAMS ((int, char **)); - /* Handle the switch CODE, which has real type enum opt_code from options.h. If the switch takes an argument, it is passed in ARG which points to permanent storage. The handler is resonsible for diff --git a/gcc/opts.c b/gcc/opts.c index 0911d388ff81..25dacf2131d2 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -118,7 +118,7 @@ find_opt (const char *input, int lang_mask) /* Handle the switch beginning at ARGV, with ARGC remaining. */ int -handle_option (int argc, char **argv, int lang_mask) +handle_option (int argc ATTRIBUTE_UNUSED, char **argv, int lang_mask) { size_t opt_index; const char *opt, *arg = 0; @@ -127,10 +127,6 @@ handle_option (int argc, char **argv, int lang_mask) int result = 0, temp; const struct cl_option *option; - /* If the front end isn't yet converted, use the old hook. */ - if (!lang_hooks.handle_option) - return (*lang_hooks.decode_option) (argc, argv); - opt = argv[0]; /* Interpret "-" or a non-switch as a file name. */ diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog index 668b6d29d797..c5c063bff6c5 100644 --- a/gcc/treelang/ChangeLog +++ b/gcc/treelang/ChangeLog @@ -1,3 +1,15 @@ +2003-06-11 Neil Booth + + * Make-lang.in: Update for option handling. + * lang.opt: New. + * tree1.c: Include opts.h and t-options.h. + (treelang_decode_option): Remove. + (treelang_handle_option): New. + * treetree.c (LANG_HOOKS_DECODE_OPTION): Remove. + (LANG_HOOKS_HANDLE_OPTION): Override. + * treetree.h (treelang_decode_option): Remove. + (treelang_handle_option): New. + 2003-06-08 Andreas Jaeger * Make-lang.in: Update. diff --git a/gcc/treelang/Make-lang.in b/gcc/treelang/Make-lang.in index ca3bd3098e68..d5e96af4bcd4 100644 --- a/gcc/treelang/Make-lang.in +++ b/gcc/treelang/Make-lang.in @@ -85,11 +85,11 @@ treelang.done: tree1$(exeext) # core compiler tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/parse.o\ $(TREE_BE_LIBS) c-convert.o c-typeck.o c-common.o c-cppbuiltin.o \ - c-decl.o attribs.o + c-decl.o attribs.o treelang/t-options.o $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \ treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/parse.o \ c-convert.o c-typeck.o c-common.o c-cppbuiltin.o c-decl.o attribs.o \ - $(TREE_BE_LIBS) + $(TREE_BE_LIBS) treelang/t-options.o # # Compiling object files from source files. @@ -98,7 +98,7 @@ tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/par treelang/tree1.o: treelang/tree1.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ flags.h toplev.h $(GGC_H) $(TREE_H) diagnostic.h treelang/treelang.h \ - input.h treelang/treetree.h \ + input.h treelang/treetree.h treelang/t-options.h \ treelang/treetree.h gt-treelang-tree1.h gtype-treelang.h treelang/treetree.o: treelang/treetree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ @@ -112,6 +112,12 @@ treelang/parse.o: treelang/parse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ treelang/lex.o: treelang/lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) diagnostic.h $(TREE_H) treelang/treelang.h input.h treelang/parse.h +treelang/t-options.c: treelang/lang.opt opts.sh treelang/t-options.h + +treelang/t-options.h: treelang/lang.opt opts.sh + AWK=$(AWK) $(SHELL) $(srcdir)/opts.sh treelang/t-options.c \ + treelang/t-options.h $(srcdir)/treelang/lang.opt + # generated files the files from lex and yacc are put into the source # directory in case someone wants to build but does not have # lex/yacc @@ -122,6 +128,7 @@ $(srcdir)/treelang/lex.c: $(srcdir)/treelang/lex.l $(srcdir)/treelang/parse.c $(srcdir)/treelang/parse.h: $(srcdir)/treelang/parse.y $(BISON) $(BISONFLAGS) -v --defines \ --output=$(srcdir)/treelang/parse.c $(srcdir)/treelang/parse.y + # -v gt-treelang-tree1.h gtype-treelang.h : s-gtype; @true @@ -230,6 +237,7 @@ treelang.mostlyclean: rm -f treelang/$$name$(exeext); \ fi ; \ done + -rm -f treelang/t-options.c treelang/t-options.h -rm -f treelang/*$(objext) -rm -f treelang/*$(coverageexts) -rm treelang.done diff --git a/gcc/treelang/lang.opt b/gcc/treelang/lang.opt new file mode 100644 index 000000000000..5d3a26686fc8 --- /dev/null +++ b/gcc/treelang/lang.opt @@ -0,0 +1,59 @@ +; Options for the treelang front end. +; Copyright (C) 2003 Free Software Foundation, Inc. +; +; This file is part of GCC. +; +; GCC is free software; you can redistribute it and/or modify it under +; the terms of the GNU General Public License as published by the Free +; Software Foundation; either version 2, or (at your option) any later +; version. +; +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY +; WARRANTY; without even the implied warranty of MERCHANTABILITY or +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +; for more details. +; +; You should have received a copy of the GNU General Public License +; along with GCC; see the file COPYING. If not, write to the Free +; Software Foundation, 59 Temple Place - Suite 330, Boston, MA +; 02111-1307, USA. + + +; This file is processed by the script opts.sh. It is a database of +; command line options, with each record separated by a blank line, +; and each field appearing on its own line. The first field is the +; command-line switch with the leading "-" removed. All options +; beginning with "f" or "W" are implicitly assumed to take a "no-" +; form; this form should not be listed. If you do not want this +; negative form and you want it to be automatically rejected, add +; RejectNegative to the second field. + +; The second field should contain "Tree". If the switch takes an +; argument, then you should also specify "Joined" and/or "Separate" to +; indicate where the argument can appear. + +; Comments can appear on their own line anwhere in the file, preceded +; by a semicolon. Whitespace is permitted before the semicolon. + +; For each switch XXX below, an enumeration constant is created by the +; script opts.sh spelt OPT_XXX, but with all non-alphanumeric +; characters replaced with an underscore. + +; Please try to keep this file in ASCII collating order. + +-help +Tree + +flexer-trace +Tree + +fparser-trace +Tree + +v +Tree + +y +Tree + +; This comment is to ensure we retain the blank line above. diff --git a/gcc/treelang/tree1.c b/gcc/treelang/tree1.c index 3a6681a9b0f6..f4e5fa84cb58 100644 --- a/gcc/treelang/tree1.c +++ b/gcc/treelang/tree1.c @@ -44,6 +44,8 @@ #include "treelang.h" #include "treetree.h" +#include "opts.h" +#include "t-options.h" extern int yyparse (void); @@ -86,98 +88,54 @@ static int version_done = 0; static unsigned int work_nesting_level = 0; -/* Process one switch - called by toplev.c. */ - +/* Process a switch - called by opts.c. */ int -treelang_decode_option (num_options_left, first_option_left) - int num_options_left ATTRIBUTE_UNUSED; - char** first_option_left; +treelang_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, + int value) { - - /* - Process options - bear in mind I may get options that are really - meant for someone else (eg the main compiler) so I have to be very - permissive. - - */ - - if (first_option_left[0][0] != '-') - return 0; - - switch (first_option_left[0][1]) - { - case '-': - if (!strcmp (first_option_left[0],"--help")) - { - if (!version_done) - { - fputs (language_string, stdout); - fputs (version_string, stdout); - fputs ("\n", stdout); - version_done = 1; - } - fprintf (stdout, "Usage: tree1 [switches] -o output input\n"); - return 1; - } - break; + enum opt_code code = (enum opt_code) scode; - case 'v': - if (!strcmp (first_option_left[0],"-v")) - { - if (!version_done) - { - fputs (language_string, stdout); - fputs (version_string, stdout); - fputs ("\n", stdout); - version_done = 1; - } - return 1; - } - break; + switch (code) + { + default: + return 0; - case 'y': - if (!strcmp (first_option_left[0],"-y")) - { - option_lexer_trace = 1; - option_parser_trace = 1; - return 1; - } + case OPT__help: + if (!version_done) + { + fputs (language_string, stdout); + fputs (version_string, stdout); + fputs ("\n", stdout); + version_done = 1; + } + fprintf (stdout, "Usage: tree1 [switches] -o output input\n"); break; - case 'f': - if (!strcmp (first_option_left[0],"-fparser-trace")) - { - option_parser_trace = 1; - return 1; - } - if (!strcmp (first_option_left[0],"-flexer-trace")) - { - option_lexer_trace = 1; - return 1; - } + case OPT_v: + if (!version_done) + { + fputs (language_string, stdout); + fputs (version_string, stdout); + fputs ("\n", stdout); + version_done = 1; + } break; - case 'w': - if (!strcmp (first_option_left[0],"-w")) - { - /* Tolerate this option but ignore it - we always put out - all warnings. */ - return 1; - } + case OPT_y: + option_lexer_trace = 1; + option_parser_trace = 1; break; - case 'W': - if (!strcmp (first_option_left[0],"-Wall")) - { - return 1; - } + case OPT_fparser_trace: + option_parser_trace = value; break; - default: + case OPT_flexer_trace: + option_lexer_trace = value; break; } - return 0; + return 1; } /* Language dependent parser setup. */ diff --git a/gcc/treelang/treetree.c b/gcc/treelang/treetree.c index ca50df4f8206..904616dbcd2e 100644 --- a/gcc/treelang/treetree.c +++ b/gcc/treelang/treetree.c @@ -114,8 +114,8 @@ extern char **file_names; #define LANG_HOOKS_NAME "GNU treelang" #undef LANG_HOOKS_FINISH #define LANG_HOOKS_FINISH treelang_finish -#undef LANG_HOOKS_DECODE_OPTION -#define LANG_HOOKS_DECODE_OPTION treelang_decode_option +#undef LANG_HOOKS_HANDLE_OPTION +#define LANG_HOOKS_HANDLE_OPTION treelang_handle_option const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; /* Tree code type/name/code tables. */ diff --git a/gcc/treelang/treetree.h b/gcc/treelang/treetree.h index f2d6e30957fd..c87b3af4da6a 100644 --- a/gcc/treelang/treetree.h +++ b/gcc/treelang/treetree.h @@ -63,7 +63,7 @@ tree tree_code_get_type (int type_num); void treelang_init_decl_processing (void); void treelang_finish (void); bool treelang_init (void); -int treelang_decode_option (int, char **); +int treelang_handle_option (size_t scode, const char *arg, int value); void treelang_parse_file (int debug_flag); void push_var_level (void); void pop_var_level (void); -- 2.43.5