This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: line number for __func__


Currently the compiler-generated symbol for __func__ has the line
number in effect at the first reference. This symbol is later
moved to the beginning of the function, which makes the line number
wrong and confuses (at least) gdb. This patch marks this symbol
with line number 0, so that no bogus line number will appear in
the debug info.

2002-08-06 Dale Johannesen <dalej@apple.com>
* c-common.c (fname_decl): Use line number 0 for
__func__, to avoid confusing debuggers.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.359
diff -u -d -b -w -c -3 -p -r1.359 c-common.c
cvs server: conflicting specifications of output style
*** c-common.c 2 Aug 2002 04:18:16 -0000 1.359
--- c-common.c 6 Aug 2002 21:36:44 -0000
*************** fname_decl (rid, id)
*** 1102,1107 ****
--- 1102,1114 ----
if (!decl)
{
tree saved_last_tree = last_tree;
+ /* If a tree is built here, it would normally have the lineno of
+ the current statement. Later this tree will be moved to the
+ beginning of the function and this line number will be wrong.
+ To avoid this problem set the lineno to 0 here; that prevents
+ it from appearing in the RTL. */
+ int saved_lineno = lineno;
+ lineno = 0;

decl = (*make_fname_decl) (id, fname_vars[ix].pretty);
if (last_tree != saved_last_tree)
*************** fname_decl (rid, id)
*** 1117,1122 ****
--- 1124,1130 ----
saved_function_name_decls)
;
}
*fname_vars[ix].decl = decl;
+ lineno = saved_lineno;
}
if (!ix && !current_function_decl)
pedwarn_with_decl (decl, "`%s' is not defined outside of function scope");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]