This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Remove set_yydebug langhook
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 24 Apr 2002 23:10:03 +0100
- Subject: Remove set_yydebug langhook
There's only one langhook left to add, that's convert() and
it's such a big job I can't face it at the moment.
Now that it's clear what is a front-end dependency and what
isn't, some things can obviously be simplified or even removed,
in addition to what I managed during the langhooks conversion.
set_yydebug is one of those; it is best passed as an argument
to the parse_file() hook. I also took the opportunity to
define YYDEBUG in one place (c-lex.h) rather than five in the
C front ends.
Bootstrapping x86 Linux. OK to commit?
Neil.
* c-common.h (c_common_parse_file): Update.
* c-lang.c (LANG_HOOKS_SET_YYDEBUG): Remove.
* c-lex.c (YYDEBUG): Get from c-lex.h.
(c_common_parse_file): Update.
* c-lex.h (YYDEBUG, yydebug): New.
* c-parse.in (YYDEBUG): Get from c-lex.h.
(c_set_yydebug): Remove.
* c-tree.h (c_set_yydebug): Remove.
* langhooks-def.h (lhd_do_nothing_i): New.
(lhd_set_yydebug, LANG_HOOKS_SET_YYDEBUG): Remove.
(LANG_HOOKS_PARSE_FILE, LANG_HOOKS_INITIALIZER): Update.
* langhooks.c (lhd_do_nothing_i): New.
(lhd_set_yydebug): Remove.
* langhooks.h (struct lang_hooks): Update.
* toplev.c (set_yydebug): New.
(compile_file): Update call to parse_file hook.
(decode_d_option): Update.
ada:
* misc.c (gnat_parse_file): Update.
cp:
* cp-lang.c (LANG_HOOKS_SET_YYDEBUG): Remove.
* cp-tree.h (cxx_set_yydebug): Die.
* lex.c (YYDEBUG): Get from c-lex.h.
(cxx_set_yydebug): Remove.
* parse.y: Include c-lex.h.
(YYDEBUG): Get from c-lex.h.
f:
* com.h (ffe_parse_file): Update.
* lex.c (ffe_parse_file): Update.
java:
* java-tree.h (java_parse_file): Update.
(java_set_yydebug): Remove.
* jcf-parse.c (yydebug): Remove.
(java_set_yydebug): Die.
(java_parse_file): Update.
* lang.c (LANG_HOOKS_SET_YYDEBUG): Remove.
objc:
* objc-lang.c (LANG_HOOKS_SET_YYDEBUG): Remove.
============================================================
Index: gcc/c-common.h
--- gcc/c-common.h 24 Apr 2002 20:40:44 -0000 1.130
+++ gcc/c-common.h 24 Apr 2002 21:50:34 -0000
@@ -568,7 +568,7 @@ extern void c_common_init_options PARAM
extern void c_common_post_options PARAMS ((void));
extern const char *c_common_init PARAMS ((const char *));
extern void c_common_finish PARAMS ((void));
-extern void c_common_parse_file PARAMS ((void));
+extern void c_common_parse_file PARAMS ((int));
extern HOST_WIDE_INT c_common_get_alias_set PARAMS ((tree));
extern bool c_promoting_integer_type_p PARAMS ((tree));
extern int self_promoting_args_p PARAMS ((tree));
============================================================
Index: gcc/c-lang.c
--- gcc/c-lang.c 24 Apr 2002 20:40:44 -0000 1.91
+++ gcc/c-lang.c 24 Apr 2002 21:50:34 -0000
@@ -72,8 +72,6 @@ static void c_post_options PARAMS ((void
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL c_warn_unused_global_decl
#undef LANG_HOOKS_PRINT_IDENTIFIER
#define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier
-#undef LANG_HOOKS_SET_YYDEBUG
-#define LANG_HOOKS_SET_YYDEBUG c_set_yydebug
#undef LANG_HOOKS_FUNCTION_ENTER_NESTED
#define LANG_HOOKS_FUNCTION_ENTER_NESTED c_push_function_context
#undef LANG_HOOKS_FUNCTION_LEAVE_NESTED
============================================================
Index: gcc/c-lex.c
--- gcc/c-lex.c 22 Apr 2002 22:25:13 -0000 1.170
+++ gcc/c-lex.c 24 Apr 2002 21:50:42 -0000
@@ -65,9 +65,6 @@ static unsigned int src_lineno;
static int header_time, body_time;
static splay_tree file_info_tree;
-/* Cause the `yydebug' variable to be defined. */
-#define YYDEBUG 1
-
/* File used for outputting assembler code. */
extern FILE *asm_out_file;
@@ -156,8 +153,15 @@ init_c_lex (filename)
the primary source file. */
void
-c_common_parse_file ()
+c_common_parse_file (set_yydebug)
+ int set_yydebug ATTRIBUTE_UNUSED;
{
+#if YYDEBUG != 0
+ yydebug = set_yydebug;
+#else
+ warning ("YYDEBUG not defined");
+#endif
+
(*debug_hooks->start_source_file) (lineno, input_filename);
cpp_finish_options (parse_in);
============================================================
Index: gcc/c-lex.h
--- gcc/c-lex.h 12 Mar 2002 23:30:24 -0000 1.25
+++ gcc/c-lex.h 24 Apr 2002 21:50:42 -0000
@@ -21,6 +21,10 @@ Software Foundation, 59 Temple Place - S
#ifndef GCC_C_LEX_H
#define GCC_C_LEX_H
+/* Cause the `yydebug' variable to be defined. */
+#define YYDEBUG 1
+extern int yydebug;
+
extern tree make_pointer_declarator PARAMS ((tree, tree));
extern int c_lex PARAMS ((tree *));
============================================================
Index: gcc/c-parse.in
--- gcc/c-parse.in 16 Apr 2002 18:35:13 -0000 1.134
+++ gcc/c-parse.in 24 Apr 2002 21:50:51 -0000
@@ -43,7 +43,7 @@ end ifc
#include "cpplib.h"
#include "intl.h"
#include "timevar.h"
-#include "c-lex.h"
+#include "c-lex.h" /* Gets YYDEBUG macro. */
#include "c-tree.h"
#include "c-pragma.h"
#include "flags.h"
@@ -61,9 +61,6 @@ end ifobjc
/* Like YYERROR but do call yyerror. */
#define YYERROR1 { yyerror ("syntax error"); YYERROR; }
-
-/* Cause the "yydebug" variable to be defined. */
-#define YYDEBUG 1
%}
%start program
@@ -3800,21 +3797,6 @@ yylex()
r = _yylex();
timevar_pop (TV_LEX);
return r;
-}
-
-/* Sets the value of the 'yydebug' variable to VALUE.
- This is a function so we don't have to have YYDEBUG defined
- in order to build the compiler. */
-
-void
-c_set_yydebug (value)
- int value;
-{
-#if YYDEBUG != 0
- yydebug = value;
-#else
- warning ("YYDEBUG not defined");
-#endif
}
/* Function used when yydebug is set, to print a token in more detail. */
============================================================
Index: gcc/c-tree.h
--- gcc/c-tree.h 20 Apr 2002 09:14:09 -0000 1.95
+++ gcc/c-tree.h 24 Apr 2002 21:50:52 -0000
@@ -160,7 +160,6 @@ extern tree lookup_objc_ivar PARAMS ((
/* in c-parse.in */
extern void c_parse_init PARAMS ((void));
-extern void c_set_yydebug PARAMS ((int));
/* in c-aux-info.c */
extern void gen_aux_info_record PARAMS ((tree, int, int, int));
============================================================
Index: gcc/langhooks-def.h
--- gcc/langhooks-def.h 24 Apr 2002 20:40:44 -0000 1.31
+++ gcc/langhooks-def.h 24 Apr 2002 21:50:53 -0000
@@ -41,6 +41,7 @@ extern HOST_WIDE_INT hook_get_alias_set_
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 HOST_WIDE_INT lhd_get_alias_set PARAMS ((tree));
@@ -52,7 +53,6 @@ extern int lhd_unsafe_for_reeval PARAMS
extern void lhd_clear_binding_stack PARAMS ((void));
extern void lhd_print_tree_nothing PARAMS ((FILE *, tree, int));
extern const char *lhd_decl_printable_name PARAMS ((tree, int));
-extern void lhd_set_yydebug PARAMS ((int));
extern rtx lhd_expand_expr PARAMS ((tree, rtx, enum machine_mode, int));
extern void lhd_print_error_function PARAMS ((struct diagnostic_context *,
const char *));
@@ -82,7 +82,7 @@ tree lhd_tree_inlining_convert_parm_for_
#define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier)
#define LANG_HOOKS_INIT lhd_do_nothing
#define LANG_HOOKS_FINISH lhd_do_nothing
-#define LANG_HOOKS_PARSE_FILE 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
@@ -108,7 +108,6 @@ tree lhd_tree_inlining_convert_parm_for_
#define LANG_HOOKS_PRINT_IDENTIFIER lhd_print_tree_nothing
#define LANG_HOOKS_PRINT_ERROR_FUNCTION lhd_print_error_function
#define LANG_HOOKS_DECL_PRINTABLE_NAME lhd_decl_printable_name
-#define LANG_HOOKS_SET_YYDEBUG lhd_set_yydebug
#define LANG_HOOKS_FUNCTION_INIT lhd_do_nothing_f
#define LANG_HOOKS_FUNCTION_FREE lhd_do_nothing_f
@@ -250,7 +249,6 @@ int lhd_tree_dump_type_quals PARAMS ((
LANG_HOOKS_PRINT_IDENTIFIER, \
LANG_HOOKS_DECL_PRINTABLE_NAME, \
LANG_HOOKS_PRINT_ERROR_FUNCTION, \
- LANG_HOOKS_SET_YYDEBUG, \
LANG_HOOKS_ATTRIBUTE_TABLE, \
LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, \
LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, \
============================================================
Index: gcc/langhooks.c
--- gcc/langhooks.c 20 Apr 2002 09:14:11 -0000 1.29
+++ gcc/langhooks.c 24 Apr 2002 21:50:53 -0000
@@ -47,6 +47,14 @@ lhd_do_nothing_t (t)
{
}
+/* Do nothing (int). */
+
+void
+lhd_do_nothing_i (i)
+ int i ATTRIBUTE_UNUSED;
+{
+}
+
/* Do nothing (function). */
void
@@ -138,16 +146,6 @@ lhd_warn_unused_global_decl (decl)
return false;
return true;
-}
-
-/* Called when -dy is given on the command line. */
-
-void
-lhd_set_yydebug (value)
- int value;
-{
- if (value)
- fprintf (stderr, "warning: no yacc/bison-generated output to debug!\n");
}
/* Set the DECL_ASSEMBLER_NAME for DECL. */
============================================================
Index: gcc/langhooks.h
--- gcc/langhooks.h 24 Apr 2002 20:40:44 -0000 1.38
+++ gcc/langhooks.h 24 Apr 2002 21:50:54 -0000
@@ -213,8 +213,9 @@ struct lang_hooks
/* Called at the end of compilation, as a finalizer. */
void (*finish) PARAMS ((void));
- /* Parses the entire file. */
- void (*parse_file) PARAMS ((void));
+ /* Parses the entire file. The argument is non-zero to cause bison
+ parsers to dump debugging information during parsing. */
+ void (*parse_file) PARAMS ((int));
/* Called immediately after parsing to clear the binding stack. */
void (*clear_binding_stack) PARAMS ((void));
@@ -326,11 +327,6 @@ struct lang_hooks
/* Called by report_error_function to print out function name. */
void (*print_error_function) PARAMS ((struct diagnostic_context *,
const char *));
-
- /* Set yydebug for bison-based parsers, when -dy is given on the
- command line. By default, if the parameter is non-zero, prints a
- warning that the front end does not use such a parser. */
- void (*set_yydebug) PARAMS ((int));
/* Pointers to machine-independent attribute tables, for front ends
using attribs.c. If one is NULL, it is ignored. Respectively, a
============================================================
Index: gcc/toplev.c
--- gcc/toplev.c 19 Apr 2002 16:21:54 -0000 1.613
+++ gcc/toplev.c 24 Apr 2002 21:51:06 -0000
@@ -126,6 +126,9 @@ static int print_single_switch PARAMS ((
static void print_switch_values PARAMS ((FILE *, int, int, const char *,
const char *, const char *));
+/* Nonzero to dump debug info whilst parsing (-dy option). */
+static int set_yydebug;
+
/* Length of line when printing switch values. */
#define MAX_LINE 75
@@ -2029,7 +2032,7 @@ compile_file ()
/* Call the parser, which parses the entire file (calling
rest_of_compilation for each function). */
- (*lang_hooks.parse_file) ();
+ (*lang_hooks.parse_file) (set_yydebug);
/* In case there were missing block closers,
get us back to the global binding level. */
@@ -3721,7 +3724,7 @@ decode_d_option (arg)
rtl_dump_and_exit = 1;
break;
case 'y':
- (*lang_hooks.set_yydebug) (1);
+ set_yydebug = 1;
break;
case 'D': /* These are handled by the preprocessor. */
case 'I':
============================================================
Index: gcc/ada/misc.c
--- gcc/ada/misc.c 24 Apr 2002 20:40:59 -0000 1.36
+++ gcc/ada/misc.c 24 Apr 2002 21:51:09 -0000
@@ -85,7 +85,7 @@ static void gnat_print_type PARAMS ((FI
static const char *gnat_printable_name PARAMS ((tree, int));
static tree gnat_eh_runtime_type PARAMS ((tree));
static int gnat_eh_type_covers PARAMS ((tree, tree));
-static void gnat_parse_file PARAMS ((void));
+static void gnat_parse_file PARAMS ((int));
static void gnat_mark_tree PARAMS ((tree));
static rtx gnat_expand_expr PARAMS ((tree, rtx, enum machine_mode,
int));
@@ -192,7 +192,8 @@ extern void _ada_gnat1drv PARAMS((void))
/* The parser for the language. For us, we process the GNAT tree. */
static void
-gnat_parse_file ()
+gnat_parse_file (set_yydebug)
+ int set_yydebug ATTRIBUTE_UNUSED;
{
/* call the target specific initializations */
__gnat_initialize();
============================================================
Index: gcc/cp/cp-lang.c
--- gcc/cp/cp-lang.c 24 Apr 2002 20:41:00 -0000 1.32
+++ gcc/cp/cp-lang.c 24 Apr 2002 21:51:10 -0000
@@ -88,8 +88,6 @@ static bool cxx_warn_unused_global_decl
#define LANG_HOOKS_DECL_PRINTABLE_NAME cxx_printable_name
#undef LANG_HOOKS_PRINT_ERROR_FUNCTION
#define LANG_HOOKS_PRINT_ERROR_FUNCTION cxx_print_error_function
-#undef LANG_HOOKS_SET_YYDEBUG
-#define LANG_HOOKS_SET_YYDEBUG cxx_set_yydebug
#undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl
============================================================
Index: gcc/cp/cp-tree.h
--- gcc/cp/cp-tree.h 24 Apr 2002 20:41:00 -0000 1.709
+++ gcc/cp/cp-tree.h 24 Apr 2002 21:51:28 -0000
@@ -3615,7 +3615,6 @@ extern void cxx_print_type PARAMS ((FI
extern void cxx_print_identifier PARAMS ((FILE *, tree, int));
extern void cxx_print_error_function PARAMS ((struct diagnostic_context *,
const char *));
-extern void cxx_set_yydebug PARAMS ((int));
extern void build_self_reference PARAMS ((void));
extern int same_signature_p PARAMS ((tree, tree));
extern void warn_hidden PARAMS ((tree));
============================================================
Index: gcc/cp/lex.c
--- gcc/cp/lex.c 31 Mar 2002 22:40:55 -0000 1.276
+++ gcc/cp/lex.c 24 Apr 2002 21:51:29 -0000
@@ -23,9 +23,6 @@ Boston, MA 02111-1307, USA. */
/* This file is the lexical analyzer for GNU C++. */
-/* Cause the `yydebug' variable to be defined. */
-#define YYDEBUG 1
-
#include "config.h"
#include "system.h"
#include "input.h"
@@ -843,22 +840,6 @@ print_parse_statistics ()
fprintf (stderr, "\n");
#endif
#endif
-#endif
-}
-
-/* Sets the value of the 'yydebug' variable to VALUE.
- This is a function so we don't have to have YYDEBUG defined
- in order to build the compiler. */
-
-void
-cxx_set_yydebug (value)
- int value;
-{
-#if YYDEBUG != 0
- extern int yydebug;
- yydebug = value;
-#else
- warning ("YYDEBUG not defined");
#endif
}
============================================================
Index: gcc/cp/parse.y
--- gcc/cp/parse.y 23 Apr 2002 20:59:04 -0000 1.253
+++ gcc/cp/parse.y 24 Apr 2002 21:51:35 -0000
@@ -28,9 +28,6 @@ Boston, MA 02111-1307, USA. */
is given. Keep this in mind when reading the actions. */
%{
-/* Cause the `yydebug' variable to be defined. */
-#define YYDEBUG 1
-
#include "config.h"
#include "system.h"
@@ -40,6 +37,7 @@ Boston, MA 02111-1307, USA. */
#include "flags.h"
#include "cp-tree.h"
#include "lex.h"
+#include "c-lex.h" /* For YYDEBUG definition. */
#include "output.h"
#include "except.h"
#include "toplev.h"
============================================================
Index: gcc/f/com.h
--- gcc/f/com.h 21 Mar 2002 18:39:29 -0000 1.25
+++ gcc/f/com.h 24 Apr 2002 21:51:35 -0000
@@ -270,7 +270,7 @@ tree ffecom_truth_value (tree expr);
tree ffecom_truth_value_invert (tree expr);
tree ffecom_type_expr (ffebld expr);
tree ffecom_which_entrypoint_decl (void);
-void ffe_parse_file (void);
+void ffe_parse_file (int);
/* Define macros. */
============================================================
Index: gcc/f/parse.c
--- gcc/f/parse.c 17 Mar 2002 20:41:44 -0000 1.11
+++ gcc/f/parse.c 24 Apr 2002 21:51:35 -0000
@@ -29,7 +29,8 @@ the Free Software Foundation, 59 Temple
extern FILE *finput;
void
-ffe_parse_file ()
+ffe_parse_file (set_yydebug)
+ int set_yydebug ATTRIBUTE_UNUSED;
{
ffewhereFile wf;
============================================================
Index: gcc/java/java-tree.h
--- gcc/java/java-tree.h 4 Apr 2002 22:19:55 -0000 1.146
+++ gcc/java/java-tree.h 24 Apr 2002 21:51:41 -0000
@@ -1036,8 +1036,7 @@ struct lang_type
#define JCF_u4 unsigned long
#define JCF_u2 unsigned short
-extern void java_set_yydebug PARAMS ((int));
-extern void java_parse_file PARAMS ((void));
+extern void java_parse_file PARAMS ((int));
extern void java_mark_tree PARAMS ((tree));
extern bool java_mark_addressable PARAMS ((tree));
extern tree java_type_for_mode PARAMS ((enum machine_mode, int));
============================================================
Index: gcc/java/jcf-parse.c
--- gcc/java/jcf-parse.c 22 Apr 2002 20:34:19 -0000 1.114
+++ gcc/java/jcf-parse.c 24 Apr 2002 21:51:44 -0000
@@ -247,8 +247,6 @@ set_source_filename (jcf, index)
#include "jcf-reader.c"
-static int yydebug;
-
tree
parse_signature (jcf, sig_index)
JCF *jcf;
@@ -262,13 +260,6 @@ parse_signature (jcf, sig_index)
JPOOL_UTF_LENGTH (jcf, sig_index));
}
-void
-java_set_yydebug (value)
- int value;
-{
- yydebug = value;
-}
-
tree
get_constant (jcf, index)
JCF *jcf;
@@ -920,7 +911,8 @@ predefined_filename_p (node)
}
void
-java_parse_file ()
+java_parse_file (set_yydebug)
+ int set_yydebug ATTRIBUTE_UNUSED;
{
int filename_count = 0;
char *list, *next;
============================================================
Index: gcc/java/lang.c
--- gcc/java/lang.c 12 Apr 2002 14:28:50 -0000 1.100
+++ gcc/java/lang.c 24 Apr 2002 21:51:45 -0000
@@ -223,8 +223,6 @@ static int dependency_tracking = 0;
#define LANG_HOOKS_INIT_OPTIONS java_init_options
#undef LANG_HOOKS_DECODE_OPTION
#define LANG_HOOKS_DECODE_OPTION java_decode_option
-#undef LANG_HOOKS_SET_YYDEBUG
-#define LANG_HOOKS_SET_YYDEBUG java_set_yydebug
#undef LANG_HOOKS_PARSE_FILE
#define LANG_HOOKS_PARSE_FILE java_parse_file
#undef LANG_HOOKS_MARK_TREE
============================================================
Index: gcc/objc/objc-lang.c
--- gcc/objc/objc-lang.c 24 Apr 2002 20:41:04 -0000 1.20
+++ gcc/objc/objc-lang.c 24 Apr 2002 21:51:45 -0000
@@ -68,8 +68,6 @@ static void objc_post_options
#define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier
#undef LANG_HOOKS_DECL_PRINTABLE_NAME
#define LANG_HOOKS_DECL_PRINTABLE_NAME objc_printable_name
-#undef LANG_HOOKS_SET_YYDEBUG
-#define LANG_HOOKS_SET_YYDEBUG c_set_yydebug
#undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL c_warn_unused_global_decl