summaryrefslogtreecommitdiff
path: root/gcc/langhooks.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-27 07:24:58 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-27 07:24:58 +0000
commitb8c23db329da6afaebde201237f25c583ba61885 (patch)
treeda9ad83a363c4d770588541c6c1fc6b8fc3e0b7a /gcc/langhooks.c
parent8fdca00ada80224bbb584a12e7c5ca8ee333b905 (diff)
downloadgcc-b8c23db329da6afaebde201237f25c583ba61885.tar.gz
* builtins.c (expand_builtin, expand_builtin_object_size,
expand_builtin_memory_chk, maybe_emit_chk_warning, maybe_emit_sprintf_chk_warning): Use new %K format string specifier for diagnostics. * expr.c (expand_expr_real_1): Likewise. * langhooks-def.h (struct diagnostic_info): Add forward decl. (lhd_print_error_function): Add third argument. * langhooks.h (struct diagnostic_info): Add forward decl. (struct lang_hooks): Add third argument to print_error_function. * diagnostic.h (diagnostic_info): Add abstract_origin field. (diagnostic_last_function_changed, diagnostic_set_last_function): Add second argument. (diagnostic_report_current_function): Likewise. * toplev.c (announce_function): Pass NULL as second argument to diagnostic_set_last_function. * diagnostic.c (diagnostic_report_current_function): Add second argument, pass it as third argument to lang_hooks.print_error_function. (default_diagnostic_starter): Pass DIAGNOSTIC as second argument to diagnostic_report_current_function. (diagnostic_report_diagnostic): Initialize diagnostic->abstract_origin and message.abstract_origin. (verbatim): Initialize abstract_origin. * pretty-print.h (text_info): Add abstract_origin field. * pretty-print.c (pp_base_format): Handle %K. * langhooks.c (lhd_print_error_function): Add third argument. If diagnostic->abstract_origin, print virtual backtrace. * c-format.c (gcc_diag_char_table, gcc_tdiag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table): Support %K. (init_dynamic_diag_info): Likewise. cp/ * error.c (cxx_print_error_function): Add third argument, pass it over to lhd_print_error_function. (cp_print_error_function): If diagnostic->abstract_origin, print virtual backtrace. * cp-tree.h (struct diagnostic_info): New forward decl. (cxx_print_error_function): Add third argument. java/ * lang.c (java_print_error_function): Add third argument. testsuite/ * lib/prune.exp: Prune also "^In function .*$" lines and "^ inlined from .*$" lines. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128830 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/langhooks.c')
-rw-r--r--gcc/langhooks.c99
1 files changed, 90 insertions, 9 deletions
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index b8e7aaacc27..4682514508d 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -381,12 +381,15 @@ 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)
+lhd_print_error_function (diagnostic_context *context, const char *file,
+ diagnostic_info *diagnostic)
{
- if (diagnostic_last_function_changed (context))
+ if (diagnostic_last_function_changed (context, diagnostic))
{
const char *old_prefix = context->printer->prefix;
- char *new_prefix = file ? file_name_as_prefix (file) : NULL;
+ tree abstract_origin = diagnostic->abstract_origin;
+ char *new_prefix = (file && abstract_origin == NULL)
+ ? file_name_as_prefix (file) : NULL;
pp_set_prefix (context->printer, new_prefix);
@@ -394,17 +397,95 @@ lhd_print_error_function (diagnostic_context *context, const char *file)
pp_printf (context->printer, _("At top level:"));
else
{
- if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
+ tree fndecl, ao;
+
+ if (abstract_origin)
+ {
+ ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin);
+ while (TREE_CODE (ao) == BLOCK && BLOCK_ABSTRACT_ORIGIN (ao))
+ ao = BLOCK_ABSTRACT_ORIGIN (ao);
+ gcc_assert (TREE_CODE (ao) == FUNCTION_DECL);
+ fndecl = ao;
+ }
+ else
+ fndecl = current_function_decl;
+
+ if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
pp_printf
- (context->printer, _("In member function %qs:"),
- lang_hooks.decl_printable_name (current_function_decl, 2));
+ (context->printer, _("In member function %qs"),
+ lang_hooks.decl_printable_name (fndecl, 2));
else
pp_printf
- (context->printer, _("In function %qs:"),
- lang_hooks.decl_printable_name (current_function_decl, 2));
+ (context->printer, _("In function %qs"),
+ lang_hooks.decl_printable_name (fndecl, 2));
+
+ while (abstract_origin)
+ {
+ location_t *locus;
+ tree block = abstract_origin;
+
+ locus = &BLOCK_SOURCE_LOCATION (block);
+ fndecl = NULL;
+ block = BLOCK_SUPERCONTEXT (block);
+ while (block && TREE_CODE (block) == BLOCK
+ && BLOCK_ABSTRACT_ORIGIN (block))
+ {
+ ao = BLOCK_ABSTRACT_ORIGIN (block);
+
+ while (TREE_CODE (ao) == BLOCK && BLOCK_ABSTRACT_ORIGIN (ao))
+ ao = BLOCK_ABSTRACT_ORIGIN (ao);
+
+ if (TREE_CODE (ao) == FUNCTION_DECL)
+ {
+ fndecl = ao;
+ break;
+ }
+ else if (TREE_CODE (ao) != BLOCK)
+ break;
+
+ block = BLOCK_SUPERCONTEXT (block);
+ }
+ if (fndecl)
+ abstract_origin = block;
+ else
+ {
+ while (block && TREE_CODE (block) == BLOCK)
+ block = BLOCK_SUPERCONTEXT (block);
+
+ if (TREE_CODE (block) == FUNCTION_DECL)
+ fndecl = block;
+ abstract_origin = NULL;
+ }
+ if (fndecl)
+ {
+ expanded_location s = expand_location (*locus);
+ pp_character (context->printer, ',');
+ pp_newline (context->printer);
+ if (s.file != NULL)
+ {
+#ifdef USE_MAPPED_LOCATION
+ if (flag_show_column && s.column != 0)
+ pp_printf (context->printer,
+ _(" inlined from %qs at %s:%d:%d"),
+ lang_hooks.decl_printable_name (fndecl, 2),
+ s.file, s.line, s.column);
+ else
+#endif
+ pp_printf (context->printer,
+ _(" inlined from %qs at %s:%d"),
+ lang_hooks.decl_printable_name (fndecl, 2),
+ s.file, s.line);
+
+ }
+ else
+ pp_printf (context->printer, _(" inlined from %qs"),
+ lang_hooks.decl_printable_name (fndecl, 2));
+ }
+ }
+ pp_character (context->printer, ':');
}
- diagnostic_set_last_function (context);
+ diagnostic_set_last_function (context, diagnostic);
pp_flush (context->printer);
context->printer->prefix = old_prefix;
free ((char*) new_prefix);