conf := types2.Config{
Context: ctxt,
GoVersion: base.Flag.Lang,
- IgnoreLabels: true, // parser already checked via syntax.CheckBranches mode
+ IgnoreBranchErrors: true, // parser already checked via syntax.CheckBranches mode
CompilerErrorMessages: true, // use error strings matching existing compiler errors
Error: func(err error) {
terr := err.(types2.Error)
func LoadPackage(filenames []string) {
base.Timer.Start("fe", "parse")
- mode := syntax.CheckBranches
-
// Limit the number of simultaneously open files.
sem := make(chan struct{}, runtime.GOMAXPROCS(0)+10)
}
defer f.Close()
- p.file, _ = syntax.Parse(fbase, f, p.error, p.pragma, mode) // errors are tracked via p.error
+ p.file, _ = syntax.Parse(fbase, f, p.error, p.pragma, syntax.CheckBranches) // errors are tracked via p.error
}()
}
}()
// Do not use casually!
FakeImportC bool
- // If IgnoreLabels is set, correct label use is not checked.
- // TODO(gri) Consolidate label checking and remove this flag.
- IgnoreLabels bool
+ // If IgnoreBranchErrors is set, branch/label errors are ignored.
+ IgnoreBranchErrors bool
// If CompilerErrorMessages is set, errors are reported using
// cmd/compile error strings to match $GOROOT/test errors.
check.stmtList(0, body.List)
- if check.hasLabel && !check.conf.IgnoreLabels {
+ if check.hasLabel && !check.conf.IgnoreBranchErrors {
check.labels(body)
}
check.hasLabel = true
break // checked in 2nd pass (check.labels)
}
+ if check.conf.IgnoreBranchErrors {
+ break
+ }
switch s.Tok {
case syntax.Break:
if ctxt&breakOk == 0 {
- if check.conf.CompilerErrorMessages {
- check.error(s, "break is not in a loop, switch, or select statement")
- } else {
- check.error(s, "break not in for, switch, or select statement")
- }
+ check.error(s, "break not in for, switch, or select statement")
}
case syntax.Continue:
if ctxt&continueOk == 0 {
- if check.conf.CompilerErrorMessages {
- check.error(s, "continue is not in a loop")
- } else {
- check.error(s, "continue not in for statement")
- }
+ check.error(s, "continue not in for statement")
}
case syntax.Fallthrough:
if ctxt&fallthroughOk == 0 {