[COMMITTED] Fix infinite loop in update_enumeration_type_from_children
Commit Message
Doug Evans writes:
> On Sun, Nov 9, 2014 at 2:05 PM, Daniel Colascione <dancol@dancol.org> wrote:
> > On 10/08/2014 06:58 AM, Doug Evans wrote:
> >> Changing the loop to a for loop is another way to go, and arguably preferable.
> >
> > Either way, it looks like this bug is unfixed in master. Now that I have
> > papers, can this patch (or an equivalent for-loop version) be committed?
>
> Hi.
> I kinda like the for-loop version better.
> I'll get that checked in today.
Committed.
2014-11-13 Doug Evans <dje@google.com>
* dwarf2read.c (update_enumeration_type_from_children): Avoid
infinite loop.
@@ -13231,7 +13231,7 @@ update_enumeration_type_from_children (struct die_info *die,
struct dwarf2_cu *cu)
{
struct obstack obstack;
- struct die_info *child_die = die->child;
+ struct die_info *child_die;
int unsigned_enum = 1;
int flag_enum = 1;
ULONGEST mask = 0;
@@ -13240,13 +13240,16 @@ update_enumeration_type_from_children (struct die_info *die,
obstack_init (&obstack);
old_chain = make_cleanup_obstack_free (&obstack);
- while (child_die != NULL && child_die->tag)
+ for (child_die = die->child;
+ child_die != NULL && child_die->tag;
+ child_die = sibling_die (child_die))
{
struct attribute *attr;
LONGEST value;
const gdb_byte *bytes;
struct dwarf2_locexpr_baton *baton;
const char *name;
+
if (child_die->tag != DW_TAG_enumerator)
continue;
@@ -13274,7 +13277,6 @@ update_enumeration_type_from_children (struct die_info *die,
a flag type, no need to look at the rest of the enumerates. */
if (!unsigned_enum && !flag_enum)
break;
- child_die = sibling_die (child_die);
}
if (unsigned_enum)