cmd/compile/internal/syntax: check fallthrough in CheckBranches mode

The parser CheckBranches mode checked correct use of break, continue,
and labels, but not of fallthrough statements.

This CL adds checking of fallthrough statements as well.

For #51456.

Change-Id: I5000388011973724f80c59a6aaf015e3bb70faea
Reviewed-on: https://go-review.googlesource.com/c/go/+/414134
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Robert Griesemer 2022-06-24 15:55:30 -07:00
parent 1821639b57
commit 6b309be7ab
3 changed files with 97 additions and 14 deletions

View file

@ -162,7 +162,7 @@ func testSyntaxErrors(t *testing.T, filename string) {
} else {
t.Errorf("%s:%s: unexpected error: %s", filename, orig, e.Msg)
}
}, nil, 0)
}, nil, CheckBranches)
if *print {
fmt.Println()