aboutsummaryrefslogtreecommitdiff
path: root/gcc/treelang
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.co.uk>2003-06-11 22:21:10 +0000
committerNeil Booth <neil@gcc.gnu.org>2003-06-11 22:21:10 +0000
commit7fb26bb00173af1f41d3df4b5a7a43be9e3f12db (patch)
tree2af8d6bf007345fd5e6e0ba2072ebff79f20b89c /gcc/treelang
parent24386c5ec6a6f91d94bb14a65f5ec8a5c84235bc (diff)
downloadgcc-7fb26bb00173af1f41d3df4b5a7a43be9e3f12db.zip
gcc-7fb26bb00173af1f41d3df4b5a7a43be9e3f12db.tar.gz
gcc-7fb26bb00173af1f41d3df4b5a7a43be9e3f12db.tar.bz2
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
Diffstat (limited to 'gcc/treelang')
-rw-r--r--gcc/treelang/ChangeLog12
-rw-r--r--gcc/treelang/Make-lang.in14
-rw-r--r--gcc/treelang/lang.opt59
-rw-r--r--gcc/treelang/tree1.c112
-rw-r--r--gcc/treelang/treetree.c4
-rw-r--r--gcc/treelang/treetree.h2
6 files changed, 120 insertions, 83 deletions
diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog
index 668b6d2..c5c063b 100644
--- a/gcc/treelang/ChangeLog
+++ b/gcc/treelang/ChangeLog
@@ -1,3 +1,15 @@
+2003-06-11 Neil Booth <neil@daikokuya.co.uk>
+
+ * 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 <aj@suse.de>
* Make-lang.in: Update.
diff --git a/gcc/treelang/Make-lang.in b/gcc/treelang/Make-lang.in
index ca3bd30..d5e96af 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 0000000..5d3a266
--- /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 3a6681a..f4e5fa8 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 ca50df4..904616d 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 f2d6e30..c87b3af 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);