compiler: don't error for goto over type or const declaration
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 5 Feb 2018 01:43:24 +0000 (01:43 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 5 Feb 2018 01:43:24 +0000 (01:43 +0000)
    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

    Reviewed-on: https://go-review.googlesource.com/91696

From-SVN: r257375

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/gogo.cc

index 257ca95199eb6cb7d834941e3b1a455c2a6e3fb6..a89373199c09e08aa8947a5a13769e36cca3c3e4 100644 (file)
@@ -1,4 +1,4 @@
-2f7ac42a3f83b78d97912ce1e86296b2af4f52b7
+0c8c4fca4b52bc2323561a432436af5343e0f7b4
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 04edb08c0314de14243dc8a3ce2291e77519d82b..ab0c27b7588f67007f33fe11139bd66ded06be87 100644 (file)
@@ -6199,9 +6199,15 @@ Bindings_snapshot::check_goto_defs(Location loc, const Block* block,
        }
       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());
+           }
+       }
     }
 }