http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52880

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-04-19 
17:42:01 UTC ---
Created attachment 27193
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27193
gcc48-pr52880.patch

This patch works for me on this testcase, not sure if it is the right fix
though.

The problem is I think in that we are moving initializers back and forth
between
constructor_elements (a vector) and constructor_pending_elts (AVL tree).  The
move from constructor_elements to AVL tree happens in set_nonincremental_init
and all constructor_elements are moved there into the AVL (and -Woverride-init
warnings emitted).  The other direction is in output_pending_init_elements,
when constructor_elements is repopulated, but nothing is removed from the AVL
tree (without -Woverride-init that is just fine, saving the need to free and
realloc AVL nodes all the time).
So, if an initializer is first added to AVL tree, then copied to
constructor_elements when all fields until .e are specified, then again moved
into AVL tree, we get a warning.

I believe that during set_nonincremental_init we should never warn about
-Woverride-init, if in incremental mode the AVL tree should be either empty, or
contain initializers already copied to constructor_elements during
output_pending_init_elements.  An attempt to override already specified
initializer should always happen in non-incremental mode IMHO, so if in
incremental mode set_nonincremental_init will happen first.

Reply via email to