Message ID | orr5kfnp22.fsf@livre.localdomain |
---|---|
State | New |
Headers | show |
> I suppose -O2 infers that new_ptr can't be NULL because it's > dereferenced before, so last will always be set before we exit the loop, > but at -O1 it doesn't. > > This patch avoids the warning, but perhaps the loop should be turned > into a do/while loop to avoid the unnecessary test. The most correct version is 'last = NULL_TREE' but then the line overflows. So I'd initialize 'last' to NULL_TREE in its declaration; OK with this change.
for gcc/ada/ChangeLog from Alexandre Oliva <aoliva@redhat.com> * gcc-interface/utils.c (update_pointer_to): Initialize last. Index: gcc/ada/gcc-interface/utils.c =================================================================== --- gcc/ada/gcc-interface/utils.c.orig 2010-06-09 07:10:50.000000000 -0300 +++ gcc/ada/gcc-interface/utils.c 2010-06-09 07:14:17.000000000 -0300 @@ -3497,7 +3497,7 @@ update_pointer_to (tree old_type, tree n /* Merge PTR in NEW_PTR. */ DECL_FIELD_CONTEXT (array_field) = new_ptr; DECL_FIELD_CONTEXT (bounds_field) = new_ptr; - for (t = new_ptr; t; last = t, t = TYPE_NEXT_VARIANT (t)) + for (last = NULL, t = new_ptr; t; last = t, t = TYPE_NEXT_VARIANT (t)) TYPE_FIELDS (t) = TYPE_FIELDS (ptr); /* Chain PTR and its variants at the end. */