From d558444b77b36a429fabb4fe24694662f8cc3d72 Mon Sep 17 00:00:00 2001
From: Bill Currie <bill@taniwha.org>
Date: Wed, 13 Jan 2010 06:24:29 +0000
Subject: [PATCH] make temp def problems a little easier to understand

 o  set return_address whenever a temp def is requested, no only when it is
    actually created.
 o  make the notices about temp reference counting problems a little more
    readable and include the name of the temp
---
 tools/qfcc/source/def.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/qfcc/source/def.c b/tools/qfcc/source/def.c
index 2bcf1cb8c..09cddc8bb 100644
--- a/tools/qfcc/source/def.c
+++ b/tools/qfcc/source/def.c
@@ -420,9 +420,9 @@ get_tempdef (type_t *type, scope_t *scope)
 		def->type = type;
 	} else {
 		def = new_def (type, va (".tmp%d", tempdef_counter++), scope);
-		def->return_addr = __builtin_return_address (0);
 		def->ofs = new_location (type, scope->space);
 	}
+	def->return_addr = __builtin_return_address (0);
 	def->freed = def->removed = def->users = 0;
 	def->next = temp_scope.next;
 	set_storage_bits (def, st_local);
@@ -446,9 +446,11 @@ free_tempdefs (void)
 				expr_t      e;
 				e.file = d->file;
 				e.line = d->line;
-				notice (&e, "temp def over-freed:%s %3d %3d %d",
+				notice (&e, "temp def over-freed:%s offs:%d users:%d "
+							"managed:%d %s",
 						pr_type_name[d->type->type],
-						d->ofs, d->users, d->managed);
+						d->ofs, d->users, d->managed,
+						d->name);
 			}
 			size = type_size (d->type) - 1;
 			if (d->expr)
@@ -480,9 +482,9 @@ reset_tempdefs (void)
 		expr_t      e;
 		e.file = d->file;
 		e.line = d->line;
-		notice (&e, "temp def under-freed:%s %3d %3d %d",
+		notice (&e, "temp def under-freed:%s ofs:%d users:%d managed:%d %s",
 				pr_type_name[d->type->type],
-				d->ofs, d->users, d->managed);
+				d->ofs, d->users, d->managed, d->name);
 	}
 	temp_scope.next = 0;
 }