This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PCH] fix some gengtype problems with ada
- From: Geoffrey Keating <geoffk at romulus dot sfbay dot redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 31 May 2002 02:07:09 -0700
- Subject: [PCH] fix some gengtype problems with ada
I managed to get an Ada compiler built for x86-linux (but,
after trying for a week, no cross-compiler to ia64-linux yet),
and so this patch fixes the gengtype problems exposed when Ada is
built.
There are also some small fixes for 64-bit machines.
Bootstrapped & tested on i686-pc-linux-gnu with gcac checking and Ada.
--
Geoff Keating <geoffk@redhat.com>
===File ~/patches/pchbranch-adafixes3.patch=================
2002-05-30 Geoffrey Keating <geoffk@redhat.com>
* gengtype.h (UNION_OR_STRUCT_P): New macro.
* gengtype.c (write_gc_structure_fields): Use it.
(write_gc_root): Use it here too.
* gengtype.c (write_gc_structure_fields): Assume that lengths
of typenames fit into an 'int'; don't pass a size_t to "%d" in
printf.
(write_gc_marker_routine_for_structure): Likewise.
(write_gc_types): Likewise.
(write_gc_root): Likewise.
Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gengtype.c,v
retrieving revision 1.1.2.22
diff -p -u -p -r1.1.2.22 gengtype.c
--- gengtype.c 23 May 2002 19:28:45 -0000 1.1.2.22
+++ gengtype.c 31 May 2002 08:15:36 -0000
@@ -984,14 +984,12 @@ write_gc_structure_fields (of, s, val, p
&& t->u.p->u.s.line.file == NULL)
fprintf (of, "%*sif (%s.%s) abort();\n", indent, "",
val, f->name);
- else if (t->u.p->kind == TYPE_STRUCT
- || t->u.p->kind == TYPE_UNION
- || t->u.p->kind == TYPE_LANG_STRUCT)
+ else if (UNION_OR_STRUCT_P (t->u.p))
fprintf (of, "%*sgt_ggc_m_%s (%s.%s);\n", indent, "",
t->u.p->u.s.tag, val, f->name);
else if (t->u.p->kind == TYPE_PARAM_STRUCT)
fprintf (of, "%*sgt_ggc_mm_%d%s_%s (%s.%s);\n", indent, "",
- strlen (t->u.p->u.param_struct.param->u.s.tag),
+ (int) strlen (t->u.p->u.param_struct.param->u.s.tag),
t->u.p->u.param_struct.param->u.s.tag,
t->u.p->u.param_struct.stru->u.s.tag,
val, f->name);
@@ -1035,9 +1033,7 @@ write_gc_structure_fields (of, s, val, p
break;
}
case TYPE_POINTER:
- if (t->u.p->u.p->kind == TYPE_STRUCT
- || t->u.p->u.p->kind == TYPE_UNION
- || t->u.p->u.p->kind == TYPE_LANG_STRUCT)
+ if (UNION_OR_STRUCT_P (t->u.p->u.p))
fprintf (of, "%*sgt_ggc_m_%s (%s.%s[i%d]);\n", indent, "",
t->u.p->u.p->u.s.tag, val, f->name,
loopcounter);
@@ -1215,7 +1211,7 @@ write_gc_marker_routine_for_structure (s
if (param == NULL)
fprintf (f, "gt_ggc_mx_%s (x_p)\n", s->u.s.tag);
else
- fprintf (f, "gt_ggc_mm_%d%s_%s (x_p)\n", strlen (param->u.s.tag),
+ fprintf (f, "gt_ggc_mm_%d%s_%s (x_p)\n", (int) strlen (param->u.s.tag),
param->u.s.tag, s->u.s.tag);
fputs (" void *x_p;\n", f);
fputs ("{\n", f);
@@ -1316,7 +1312,7 @@ write_gc_types (structures, param_struct
/* Declare the marker procedure. */
fprintf (header_file,
"extern void gt_ggc_mm_%d%s_%s PARAMS ((void *));\n",
- strlen (param->u.s.tag), param->u.s.tag,
+ (int) strlen (param->u.s.tag), param->u.s.tag,
stru->u.s.tag);
if (stru->u.s.line.file == NULL)
@@ -1538,15 +1534,14 @@ write_gc_root (f, v, type, name, has_len
tp = type->u.p;
- if (! has_length
- && (tp->kind == TYPE_UNION || tp->kind == TYPE_STRUCT))
+ if (! has_length && UNION_OR_STRUCT_P (tp))
{
fprintf (f, " >_ggc_mx_%s\n", tp->u.s.tag);
}
else if (! has_length && tp->kind == TYPE_PARAM_STRUCT)
{
fprintf (f, " >_ggc_mm_%d%s_%s",
- strlen (tp->u.param_struct.param->u.s.tag),
+ (int) strlen (tp->u.param_struct.param->u.s.tag),
tp->u.param_struct.param->u.s.tag,
tp->u.param_struct.stru->u.s.tag);
}
Index: gengtype.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gengtype.h,v
retrieving revision 1.1.2.9
diff -p -u -p -r1.1.2.9 gengtype.h
--- gengtype.h 22 May 2002 19:36:34 -0000 1.1.2.9
+++ gengtype.h 31 May 2002 08:15:36 -0000
@@ -95,6 +95,10 @@ struct type {
((x)->kind == TYPE_UNION || \
((x)->kind == TYPE_LANG_STRUCT \
&& (x)->u.s.lang_struct->kind == TYPE_UNION))
+#define UNION_OR_STRUCT_P(x) \
+ ((x)->kind == TYPE_UNION \
+ || (x)->kind == TYPE_STRUCT \
+ || (x)->kind == TYPE_LANG_STRUCT)
/* The one and only TYPE_STRING. */
extern struct type string_type;
============================================================