This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: toplevel error location
- To: egcs-patches at egcs dot cygnus dot com
- Subject: PATCH: toplevel error location
- From: Nathan Sidwell <nathan at acm dot org>
- Date: Mon, 19 Apr 1999 13:32:52 +0100
- Organization: University of Bristol
- Reply-To: nathan at compsci dot bristol dot ac dot uk
Hi,
here's a patch for http://egcs.cygnus.com/ml/egcs-bugs/1999-04/msg00243.html
It modifies report_error_function (toplev.c) in the following manner
1) Ignore the FILE argument, it might be incorrect when delivered via
error_with_file_and_line and the like (such as cp_error_at).
2) Print #include stack before announcing the function
4) Pass input_filename to announce the function. I believe input_filename is
always correct.
Although I attach a test case, the testsuite doesn't check such niceties of the
diagnostic output -- but you can use it manually to see the difference.
enjoy
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
You can up the bandwidth, but you can't up the speed of light
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk
egcs/gcc/ChangeLog:
Sat Apr 17 13:47:08 BST 1999 Nathan Sidwell <nathan@acm.org>
* toplev.c (report_error_function): Reorder file stack and
function name printing. Ignore FILE parameter.
*** egcs/gcc/toplev.c.orig Sat Apr 17 13:38:13 1999
--- egcs/gcc/toplev.c Sat Apr 17 13:49:17 1999
*************** void (*print_error_function) PROTO((cons
*** 1540,1550 ****
default_print_error_function;
/* Prints out, if necessary, the name of the current function
! that caused an error. Called from all error and warning functions. */
void
report_error_function (file)
! const char *file;
{
struct file_stack *p;
--- 1540,1551 ----
default_print_error_function;
/* Prints out, if necessary, the name of the current function
! that caused an error. Called from all error and warning functions.
! We ignore the FILE parameter, as it cannot be relied upon. */
void
report_error_function (file)
! const char *file ATTRIBUTE_UNUSED;
{
struct file_stack *p;
*************** report_error_function (file)
*** 1554,1564 ****
need_error_newline = 0;
}
- (*print_error_function) (file);
-
if (input_file_stack && input_file_stack->next != 0
! && input_file_stack_tick != last_error_tick
! && file == input_filename)
{
for (p = input_file_stack->next; p; p = p->next)
notice ((p == input_file_stack->next
--- 1555,1562 ----
need_error_newline = 0;
}
if (input_file_stack && input_file_stack->next != 0
! && input_file_stack_tick != last_error_tick)
{
for (p = input_file_stack->next; p; p = p->next)
notice ((p == input_file_stack->next
*************** report_error_function (file)
*** 1568,1573 ****
--- 1566,1573 ----
fprintf (stderr, ":\n");
last_error_tick = input_file_stack_tick;
}
+
+ (*print_error_function) (input_filename);
}
/* Print a message. */
// Build don't link:
// Copyright (C) 1999 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 17 Apr 1999 <nathan@acm.org>
// Function introducers and file stack printing are awkeardly ordered wrt the
// error messages. If the first error in a function is cp_error_at, the
// function is introduced *afterwards* -- this is confusing
# 1 "baz.cc"
# 1 "bazB.h" 1
# 1 "bazA.h" 1
struct A
{
protected:
int m; // ERROR protected
};
inline void fn(A a)
{
a.m; // ERROR within this context
}
# 1 "bazB.h" 2
struct B : A
{
inline void foo(A *);
};
inline void B::foo(A *ptr)
{
ptr->m; // ERROR within this context
}
# 1 "baz.cc" 2