compiler: set "need_init_fn" when adding gc root

Variables that back slice initializers in certain cases have to be
added to the gc roots list, since they can be modified at runtime. The
code that was doing this addition did not update the flag that tracks
whether the package being compiled needs an initializer function,
which resulted in the call in question being left out of the final
generated code in certain cases. Fix is to change Gogo::add_gc_root()
to update the "needs init" flag.

Change-Id: Ic1da437a470716e99778592bc185ebd4ed8488c0
Reviewed-on: https://go-review.googlesource.com/43030
Reviewed-by: Ian Lance Taylor <iant@golang.org>
1 file changed