Convert treelang/ to opts.c.
Neil Booth
neil@daikokuya.co.uk
Wed Jun 11 21:37:00 GMT 2003
This converts treelang in the same spirit as the other front ends,
and removes the langhook that becomes obsolete.
I forgot to update the mostlyclean target for Java.
Neil.
* 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.
Index: hooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hooks.c,v
retrieving revision 1.14
diff -u -p -b -r1.14 hooks.c
--- hooks.c 7 Jun 2003 11:10:39 -0000 1.14
+++ hooks.c 11 Jun 2003 21:28:42 -0000
@@ -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;
Index: hooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hooks.h,v
retrieving revision 1.14
diff -u -p -b -r1.14 hooks.h
--- hooks.h 7 Jun 2003 11:10:39 -0000 1.14
+++ hooks.h 11 Jun 2003 21:28:42 -0000
@@ -40,6 +40,7 @@ void hook_void_tree_treeptr PARAMS ((tre
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));
Index: langhooks-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v
retrieving revision 1.49
diff -u -p -b -r1.49 langhooks-def.h
--- langhooks-def.h 10 Jun 2003 16:43:37 -0000 1.49
+++ langhooks-def.h 11 Jun 2003 21:28:43 -0000
@@ -35,9 +35,7 @@ extern HOST_WIDE_INT hook_get_alias_set_
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 ((
#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 ((
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, \
Index: langhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.c,v
retrieving revision 1.42
diff -u -p -b -r1.42 langhooks.c
--- langhooks.c 10 Jun 2003 16:43:37 -0000 1.42
+++ langhooks.c 11 Jun 2003 21:28:43 -0000
@@ -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
Index: langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.57
diff -u -p -b -r1.57 langhooks.h
--- langhooks.h 10 Jun 2003 16:43:37 -0000 1.57
+++ langhooks.h 11 Jun 2003 21:28:43 -0000
@@ -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
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.2
diff -u -p -b -r1.2 opts.c
--- opts.c 8 Jun 2003 07:54:10 -0000 1.2
+++ opts.c 11 Jun 2003 21:28:43 -0000
@@ -118,7 +118,7 @@ find_opt (const char *input, int lang_ma
/* 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;
@@ -126,10 +126,6 @@ handle_option (int argc, char **argv, in
bool on = true;
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];
Index: java/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Make-lang.in,v
retrieving revision 1.112
diff -u -p -b -r1.112 Make-lang.in
--- java/Make-lang.in 10 Jun 2003 16:57:46 -0000 1.112
+++ java/Make-lang.in 11 Jun 2003 21:28:44 -0000
@@ -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:
Index: treelang/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/Make-lang.in,v
retrieving revision 1.24
diff -u -p -b -r1.24 Make-lang.in
--- treelang/Make-lang.in 8 Jun 2003 14:22:24 -0000 1.24
+++ treelang/Make-lang.in 11 Jun 2003 21:28:46 -0000
@@ -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 treelan
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 $(CON
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)/tree
$(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
Index: treelang/lang.opt
===================================================================
RCS file: treelang/lang.opt
diff -N treelang/lang.opt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ treelang/lang.opt 11 Jun 2003 21:28:46 -0000
@@ -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.
Index: treelang/tree1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/tree1.c,v
retrieving revision 1.8
diff -u -p -b -r1.8 tree1.c
--- treelang/tree1.c 6 May 2003 09:18:46 -0000 1.8
+++ treelang/tree1.c 11 Jun 2003 21:28:46 -0000
@@ -44,6 +44,8 @@
#include "treelang.h"
#include "treetree.h"
+#include "opts.h"
+#include "t-options.h"
extern int yyparse (void);
@@ -86,29 +88,19 @@ 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)
{
+ enum opt_code code = (enum opt_code) scode;
- /*
- 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] != '-')
+ switch (code)
+ {
+ default:
return 0;
- switch (first_option_left[0][1])
- {
- case '-':
- if (!strcmp (first_option_left[0],"--help"))
- {
+ case OPT__help:
if (!version_done)
{
fputs (language_string, stdout);
@@ -117,13 +109,9 @@ treelang_decode_option (num_options_left
version_done = 1;
}
fprintf (stdout, "Usage: tree1 [switches] -o output input\n");
- return 1;
- }
break;
- case 'v':
- if (!strcmp (first_option_left[0],"-v"))
- {
+ case OPT_v:
if (!version_done)
{
fputs (language_string, stdout);
@@ -131,53 +119,23 @@ treelang_decode_option (num_options_left
fputs ("\n", stdout);
version_done = 1;
}
- return 1;
- }
break;
- case 'y':
- if (!strcmp (first_option_left[0],"-y"))
- {
+ case OPT_y:
option_lexer_trace = 1;
option_parser_trace = 1;
- return 1;
- }
- 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;
- }
- break;
-
- case 'w':
- if (!strcmp (first_option_left[0],"-w"))
- {
- /* Tolerate this option but ignore it - we always put out
- all warnings. */
- return 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. */
Index: treelang/treetree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/treetree.c,v
retrieving revision 1.24
diff -u -p -b -r1.24 treetree.c
--- treelang/treetree.c 8 Jun 2003 14:22:24 -0000 1.24
+++ treelang/treetree.c 11 Jun 2003 21:28:46 -0000
@@ -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. */
Index: treelang/treetree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/treetree.h,v
retrieving revision 1.5
diff -u -p -b -r1.5 treetree.h
--- treelang/treetree.h 6 May 2003 09:18:46 -0000 1.5
+++ treelang/treetree.h 11 Jun 2003 21:28:46 -0000
@@ -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);
More information about the Gcc-patches
mailing list