compiler: don't error for goto over type or const declaration

We should only issue an error for a goto over a var declaration.

The test case for this is already in the master repository, at
test/fixedbugs/issue8042.go.  It just hasn't been copied into the
gccgo repository yet.

Fixes golang/go#19089

Change-Id: I2868b2d01026b61fd700005b332fbf453bb946bf
Reviewed-on: https://go-review.googlesource.com/91696
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/go/gogo.cc b/go/gogo.cc
index 04edb08..ab0c27b 100644
--- a/go/gogo.cc
+++ b/go/gogo.cc
@@ -6199,9 +6199,15 @@
 	}
       go_assert(p != block->bindings()->end_definitions());
 
-      std::string n = (*p)->message_name();
-      go_error_at(loc, "goto jumps over declaration of %qs", n.c_str());
-      go_inform((*p)->location(), "%qs defined here", n.c_str());
+      for (; p != block->bindings()->end_definitions(); ++p)
+	{
+	  if ((*p)->is_variable())
+	    {
+	      std::string n = (*p)->message_name();
+	      go_error_at(loc, "goto jumps over declaration of %qs", n.c_str());
+	      go_inform((*p)->location(), "%qs defined here", n.c_str());
+	    }
+	}
     }
 }