From 98a32a4c844e96d0ca734ce33e3912b22820921d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 10 Nov 2016 11:49:08 -0500 Subject: [PATCH] gengtype.c (new_structure): Append to structures list. * gengtype.c (new_structure): Append to structures list. (find_structure): Likewise. From-SVN: r242040 --- gcc/ChangeLog | 5 +++++ gcc/gengtype.c | 13 ++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e13f598d6f..4a380cbf460 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-11-10 Jason Merrill + + * gengtype.c (new_structure): Append to structures list. + (find_structure): Likewise. + 2016-11-10 Jim Wilson * tree-loop-distribution.c (pg_add_dependence_edges): Return 2 if diff --git a/gcc/gengtype.c b/gcc/gengtype.c index 760f9859184..a5795473b73 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -744,10 +744,11 @@ new_structure (const char *name, enum typekind kind, struct fileloc *pos, type_p s = NULL; lang_bitmap bitmap = get_lang_bitmap (pos->file); bool isunion = (kind == TYPE_UNION); + type_p *p = &structures; gcc_assert (union_or_struct_p (kind)); - for (si = structures; si != NULL; si = si->next) + for (si = structures; si != NULL; p = &si->next, si = *p) if (strcmp (name, si->u.s.tag) == 0 && UNION_P (si) == isunion) { type_p ls = NULL; @@ -793,8 +794,7 @@ new_structure (const char *name, enum typekind kind, struct fileloc *pos, type_count++; s = XCNEW (struct type); s->state_number = -type_count; - s->next = structures; - structures = s; + *p = s; } if (s->u.s.lang_struct && (s->u.s.lang_struct->u.s.bitmap & bitmap)) @@ -829,21 +829,20 @@ find_structure (const char *name, enum typekind kind) { type_p s; bool isunion = (kind == TYPE_UNION); + type_p *p = &structures; gcc_assert (kind == TYPE_UNDEFINED || union_or_struct_p (kind)); - for (s = structures; s != NULL; s = s->next) + for (s = structures; s != NULL; p = &s->next, s = *p) if (strcmp (name, s->u.s.tag) == 0 && UNION_P (s) == isunion) return s; type_count++; s = XCNEW (struct type); - s->next = structures; s->state_number = -type_count; - structures = s; s->kind = kind; s->u.s.tag = name; - structures = s; + *p = s; return s; } -- 2.30.2