cmd/gc: fix nil pointer dereferences.

Fixes issue 5119.

R=golang-dev, dvyukov, dave, rsc
CC=golang-dev
https://codereview.appspot.com/7838050