diff options
author | gdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-09-07 10:11:28 +0000 |
---|---|---|
committer | gdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-09-07 10:11:28 +0000 |
commit | 2a576742fab3c384196446017f65f4ce9077ceb7 (patch) | |
tree | cf1ec8b78316a2d95e298530826a3c04d994ca76 /gcc/langhooks.c | |
parent | 65eab36715ef2bb6e34c683a34897b17ab6d7b12 (diff) | |
download | gcc-2a576742fab3c384196446017f65f4ce9077ceb7.tar.gz |
* langhooks.c (lhd_print_error_function): Move from diagnostic.c.
* Makefile.in (langhooks.o): Depend on diagnostic.h
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71165 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/langhooks.c')
-rw-r--r-- | gcc/langhooks.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 665a06a5569..622e0626801 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -33,6 +33,7 @@ Boston, MA 02111-1307, USA. */ #include "langhooks.h" #include "langhooks-def.h" #include "ggc.h" +#include "diagnostic.h" /* Do nothing; in many cases the default hook. */ @@ -493,4 +494,38 @@ lhd_initialize_diagnostics (struct diagnostic_context *ctx ATTRIBUTE_UNUSED) { } +/* The default function to print out name of current function that caused + an error. */ +void +lhd_print_error_function (diagnostic_context *context, const char *file) +{ + if (diagnostic_last_function_changed (context)) + { + const char *old_prefix = context->printer->prefix; + char *new_prefix = file ? file_name_as_prefix (file) : NULL; + + pp_set_prefix (context->printer, new_prefix); + + if (current_function_decl == NULL) + pp_printf (context->printer, "At top level:"); + else + { + if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) + pp_printf + (context->printer, "In member function `%s':", + (*lang_hooks.decl_printable_name) (current_function_decl, 2)); + else + pp_printf + (context->printer, "In function `%s':", + (*lang_hooks.decl_printable_name) (current_function_decl, 2)); + } + pp_newline (context->printer); + + diagnostic_set_last_function (context); + pp_flush (context->printer); + context->printer->prefix = old_prefix; + free ((char*) new_prefix); + } +} + #include "gt-langhooks.h" |