From b40729e22bdbfdf474a15f4b61305bcdd32c25e3 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 31 Mar 2002 22:32:05 +0000 Subject: * diagnostic.c (print_error_function): Remove. (default_print_error_function): Rename. (report_error_function): Update. * diagnostic.h (print_error_function): Remove. (default_print_error_function): Remove. * langhooks-def.h (struct diagnostic_context): Predeclare. (lhd_print_error_function, LANG_HOOKS_PRINT_ERROR_FUNCTION): New. (LANG_HOOKS_INITIALIZER): Update. * langhooks.h (struct diagnostic context): Predeclare. (struct lang_hooks): New hook. cp: * Make-lang.in (error.o): Update. * cp-lang.c (LANG_HOOKS_PRINT_ERROR_FUNCTION): Redefine. * cp-tree.h (struct diagnostic_context): Predeclare. (cxx_print_error_function): New. * error.c: Include langhooks-def.h. (lang_print_error_function): Rename. Update. (init_error): Don't set hook. f: * com.c (lang_print_error_function): Rename. (LANG_HOOKS_PRINT_ERROR_FUNCTION): Redefine. (ffe_init): Don't set hook. java: * lang.c (LANG_HOOKS_PRINT_ERROR_FUNCTION): Redefine. (java_dummy_print): Remove. (lang_print_error): Rename. Exit early if inhibiting output. (inhibit_error_printing_function): New. (java_init): Don't set hook. (lang_init_source): Use new boolean. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@51672 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/java/lang.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'gcc/java/lang.c') diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 583af75eaf1..b56eea4ab16 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -54,8 +54,8 @@ static void java_init_options PARAMS ((void)); static int java_decode_option PARAMS ((int, char **)); static void put_decl_string PARAMS ((const char *, int)); static void put_decl_node PARAMS ((tree)); -static void java_dummy_print PARAMS ((diagnostic_context *, const char *)); -static void lang_print_error PARAMS ((diagnostic_context *, const char *)); +static void java_print_error_function PARAMS ((diagnostic_context *, + const char *)); static int process_option_with_no PARAMS ((const char *, const struct string_option *, int)); @@ -101,6 +101,10 @@ const char *const tree_code_name[] = { }; #undef DEFTREECODE +/* Used to avoid printing error messages with bogus function + prototypes. Starts out false. */ +static bool inhibit_error_function_printing; + int compiling_from_source; char * resource_name; @@ -231,6 +235,8 @@ static int dependency_tracking = 0; #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL java_dup_lang_specific_decl #undef LANG_HOOKS_DECL_PRINTABLE_NAME #define LANG_HOOKS_DECL_PRINTABLE_NAME lang_printable_name +#undef LANG_HOOKS_PRINT_ERROR_FUNCTION +#define LANG_HOOKS_PRINT_ERROR_FUNCTION java_print_error_function #undef LANG_HOOKS_TYPE_FOR_MODE #define LANG_HOOKS_TYPE_FOR_MODE java_type_for_mode #undef LANG_HOOKS_TYPE_FOR_SIZE @@ -516,8 +522,6 @@ java_init (filename) jcf_path_init (); jcf_path_seal (version_flag); - print_error_function = lang_print_error; - java_init_decl_processing (); using_eh_for_cleanups (); @@ -643,7 +647,7 @@ put_decl_node (node) /* Return a user-friendly name for DECL. The resulting string is only valid until the next call. The value of the hook decl_printable_name is this function, - which is also called directly by lang_print_error. */ + which is also called directly by java_print_error_function. */ const char * lang_printable_name (decl, v) @@ -672,10 +676,10 @@ lang_printable_name_wls (decl, v) } /* Print on stderr the current class and method context. This function - is the value of the hook print_error_function, called from toplev.c. */ + is the value of the hook print_error_function. */ static void -lang_print_error (context, file) +java_print_error_function (context, file) diagnostic_context *context __attribute__((__unused__)); const char *file; { @@ -692,6 +696,10 @@ lang_print_error (context, file) initialized_p = 1; } + /* Don't print error messages with bogus function prototypes. */ + if (inhibit_error_function_printing) + return; + if (current_function_decl != NULL && DECL_CONTEXT (current_function_decl) != last_error_function_context) { @@ -723,31 +731,17 @@ lang_print_error (context, file) } -/* This doesn't do anything on purpose. It's used to satisfy the - print_error_function hook we don't print error messages with bogus - function prototypes. */ - -static void -java_dummy_print (c, s) - diagnostic_context *c __attribute__ ((__unused__)); - const char *s __attribute__ ((__unused__)); -{ -} - /* Called to install the PRINT_ERROR_FUNCTION hook differently according to LEVEL. LEVEL is 1 during early parsing, when function - prototypes aren't fully resolved. print_error_function is set so it - doesn't print incomplete function prototypes. When LEVEL is 2, - function prototypes are fully resolved and can be printed when + prototypes aren't fully resolved. java_print_error_function is set + so it doesn't print incomplete function prototypes. When LEVEL is + 2, function prototypes are fully resolved and can be printed when reporting errors. */ void lang_init_source (level) int level; { - if (level == 1) - print_error_function = java_dummy_print; - else - print_error_function = lang_print_error; + inhibit_error_function_printing = (level == 1); } static void -- cgit v1.2.3