This is the mail archive of the 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]

Minor bugfix/improvement for gengtype

As long as I was testing a fix for Rask's problem with
define_constraints, I thought I'd dust off this little patch and send
it in.  For reasons which I can no longer remember, I was rewriting
gengtype's parser back at the beginning of the summer.  It is unlikely
that I will finish that anytime soon, what with classes back in
session and me not being especially motivated to work on it since I
can't remember why I was doing it in the first place. :-)  However, in
the process I discovered an arguable bug in the handling of
GTY((skip)) fields; the fix for that is easily separated from the rest
of the rewrite, and since it is (arguably) a bug, I don't mind sending
it in now instead of continuing to wait for stage 1.

The bug is simply that set_gc_used_type doesn't pay attention to
"skip"; this causes all those annoying "<type> used but not defined"
warnings during bootstrap, and more significantly, causes gengtype to
write out mark functions for all those types.  The functions are
incorrect, since gengtype doesn't actually know how to mark those
types; fortunately, they also go unreferenced, so the only effect is
to waste space in the cc1 image.

The fix is straightforward.  Bootstrapped i686-linux (along with the
patch for Rask's problem); all the warnings go away and I manually
verified that the only change in gengtype's output is to cease
generating those unused mark functions.


       * gengtype.c (process_gc_options): Remove unnecessary forward decl.
       Add another out parameter, "skip".
       (set_gc_used_type): Adjust calls to process_gc_options.  If a field is
       tagged "skip", do not mark its type used.
--- gengtype.c	(revision 117474)
+++ gengtype.c	(local)
@@ -870,8 +870,6 @@ note_yacc_type (options_p o, pair_p fiel
   do_typedef ("YYSTYPE", new_structure ("yy_union", 1, pos, typeinfo, o), pos);
-static void process_gc_options (options_p, enum gc_used_enum,
-				int *, int *, int *, type_p *);
 static void set_gc_used_type (type_p, enum gc_used_enum, type_p *);
 static void set_gc_used (pair_p);
@@ -879,7 +877,7 @@ static void set_gc_used (pair_p);
 static void
 process_gc_options (options_p opt, enum gc_used_enum level, int *maybe_undef,
-		    int *pass_param, int *length, type_p *nested_ptr)
+		    int *pass_param, int *length, int *skip, type_p *nested_ptr)
   options_p o;
   for (o = opt; o; o = o->next)
@@ -891,6 +889,8 @@ process_gc_options (options_p opt, enum 
       *pass_param = 1;
     else if (strcmp (o->name, "length") == 0)
       *length = 1;
+    else if (strcmp (o->name, "skip") == 0)
+      *skip = 1;
     else if (strcmp (o->name, "nested_ptr") == 0)
       *nested_ptr = ((const struct nested_ptr_data *) o->info)->type;
@@ -914,7 +914,7 @@ set_gc_used_type (type_p t, enum gc_used
 	int dummy;
 	type_p dummy2;
-	process_gc_options (t->u.s.opt, level, &dummy, &dummy, &dummy,
+	process_gc_options (t->u.s.opt, level, &dummy, &dummy, &dummy, &dummy,
 	for (f = t->u.s.fields; f; f = f->next)
@@ -922,9 +922,10 @@ set_gc_used_type (type_p t, enum gc_used
 	    int maybe_undef = 0;
 	    int pass_param = 0;
 	    int length = 0;
+	    int skip = 0;
 	    type_p nested_ptr = NULL;
 	    process_gc_options (f->opt, level, &maybe_undef, &pass_param,
-				&length, &nested_ptr);
+				&length, &skip, &nested_ptr);
 	    if (nested_ptr && f->type->kind == TYPE_POINTER)
 	      set_gc_used_type (nested_ptr, GC_POINTED_TO, 
@@ -936,6 +937,8 @@ set_gc_used_type (type_p t, enum gc_used
 	    else if (pass_param && f->type->kind == TYPE_POINTER && param)
 	      set_gc_used_type (find_param_structure (f->type->u.p, param),
+	    else if (skip)
+	      ; /* target type is not used through this field */
 	      set_gc_used_type (f->type, GC_USED, pass_param ? param : NULL);

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