File tree 1 file changed +18
-7
lines changed
src/cmd/compile/internal/gc
1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -496,8 +496,14 @@ func (s *state) stmt(n *Node) {
496
496
// Provide a block for the dead code so that we don't have
497
497
// to add special cases everywhere else.
498
498
if s .curBlock == nil {
499
- dead := s .f .NewBlock (ssa .BlockPlain )
500
- s .startBlock (dead )
499
+ switch n .Op {
500
+ case OLABEL , OBREAK , OCONTINUE :
501
+ // These statements don't need a block,
502
+ // and they commonly occur without one.
503
+ default :
504
+ dead := s .f .NewBlock (ssa .BlockPlain )
505
+ s .startBlock (dead )
506
+ }
501
507
}
502
508
503
509
s .stmtList (n .Ninit )
@@ -604,9 +610,12 @@ func (s *state) stmt(n *Node) {
604
610
lab .target = s .f .NewBlock (ssa .BlockPlain )
605
611
}
606
612
607
- // go to that label (we pretend "label:" is preceded by "goto label")
608
- b := s .endBlock ()
609
- b .AddEdgeTo (lab .target )
613
+ // Go to that label.
614
+ // (We pretend "label:" is preceded by "goto label", unless the predecessor is unreachable.)
615
+ if s .curBlock != nil {
616
+ b := s .endBlock ()
617
+ b .AddEdgeTo (lab .target )
618
+ }
610
619
s .startBlock (lab .target )
611
620
612
621
case OGOTO :
@@ -826,8 +835,10 @@ func (s *state) stmt(n *Node) {
826
835
}
827
836
}
828
837
829
- b := s .endBlock ()
830
- b .AddEdgeTo (to )
838
+ if s .curBlock != nil {
839
+ b := s .endBlock ()
840
+ b .AddEdgeTo (to )
841
+ }
831
842
832
843
case OFOR :
833
844
// OFOR: for Ninit; Left; Right { Nbody }
You can’t perform that action at this time.
0 commit comments