This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH:diagnostics for global dtors
- To: egcs-patches at cygnus dot com
- Subject: PATCH:diagnostics for global dtors
- From: Nathan Sidwell <nathan at acm dot org>
- Date: Wed, 16 Dec 1998 15:58:46 +0000
- Organization: Computer Science Dept, Bristol University
Hi,
I came across a problem with egcs++ reporting errors during generating
static destructors. This is done after parsing the whole file, and hence
the current filename and line number are the end of the compilation
unit, not the location of the variable definition. This also means the
debugger gets the locations wrong.
Here's a patch to do_dtors which sets input_filename, lineno and emits a
note about that. do_ctors already had this logic, so no change is
necessary there.
The patch is against the 19981213 snapshot.
I also attach a test case, you can see the
dtordiag.ii:4: `A::~A()' is private
dtordiag.ii:9: within this context
changes to a more informative
dtordiag.ii:4: `A::~A()' is private
dtordiag.ii:7: within this context
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/cp/ChangeLog
Wed Dec 16 15:45:23 BST 1998 Nathan Sidwell <nathan@acm.org>
* decl2.c (do_dtors): Set current location to that of the
decl, for sensible diagnostics and debugging.
Index: egcs/gcc/cp/decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.167
diff -c -3 -p -r1.167 decl2.c
*** decl2.c 1998/12/09 12:48:42 1.167
--- decl2.c 1998/12/16 15:44:48
*************** do_dtors (start)
*** 3093,3098 ****
--- 3096,3107 ----
if (! current_function_decl)
start_objects ('D', initp);
+ /* Set these global variables so that GDB at least puts
+ us near the declaration which required the initialization. */
+ input_filename = DECL_SOURCE_FILE (decl);
+ lineno = DECL_SOURCE_LINE (decl);
+ emit_note (input_filename, lineno);
+
/* Because of:
[class.access.spec]
class A
{
A();
~A();
};
static A a;