aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2024-09-04 13:14:17 -0400
committerAlan Donovan <adonovan@google.com>2024-09-04 18:16:59 +0000
commitcd9a300afc0be43f7ad1891a18ed9b690f7f97ab (patch)
treec75ebe4996e022d37078729224083101193d2e69 /src/cmd/compile/internal/syntax
parent21ac23a96f204dfb558a8d3071380c1d105a93ba (diff)
downloadgo-cd9a300afc0be43f7ad1891a18ed9b690f7f97ab.tar.xz
all: fix printf(var) mistakes detected by latest printf checker
These will cause build failures once we vendor x/tools. In once case I renamed a function err to errf to indicate that it is printf-like. Updates golang/go#68796 Change-Id: I04d57b34ee5362f530554b7e8b817f70a9088d12 Reviewed-on: https://go-review.googlesource.com/c/go/+/610739 Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Tim King <taking@google.com> Auto-Submit: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax')
-rw-r--r--src/cmd/compile/internal/syntax/branches.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/syntax/branches.go b/src/cmd/compile/internal/syntax/branches.go
index 3d7ffed374..8b360176e8 100644
--- a/src/cmd/compile/internal/syntax/branches.go
+++ b/src/cmd/compile/internal/syntax/branches.go
@@ -29,9 +29,9 @@ func checkBranches(body *BlockStmt, errh ErrorHandler) {
name := fwd.Label.Value
if l := ls.labels[name]; l != nil {
l.used = true // avoid "defined and not used" error
- ls.err(fwd.Label.Pos(), "goto %s jumps into block starting at %s", name, l.parent.start)
+ ls.errf(fwd.Label.Pos(), "goto %s jumps into block starting at %s", name, l.parent.start)
} else {
- ls.err(fwd.Label.Pos(), "label %s not defined", name)
+ ls.errf(fwd.Label.Pos(), "label %s not defined", name)
}
}
@@ -39,7 +39,7 @@ func checkBranches(body *BlockStmt, errh ErrorHandler) {
for _, l := range ls.labels {
if !l.used {
l := l.lstmt.Label
- ls.err(l.Pos(), "label %s defined and not used", l.Value)
+ ls.errf(l.Pos(), "label %s defined and not used", l.Value)
}
}
}
@@ -61,7 +61,7 @@ type block struct {
lstmt *LabeledStmt // labeled statement associated with this block, or nil
}
-func (ls *labelScope) err(pos Pos, format string, args ...interface{}) {
+func (ls *labelScope) errf(pos Pos, format string, args ...interface{}) {
ls.errh(Error{pos, fmt.Sprintf(format, args...)})
}
@@ -75,7 +75,7 @@ func (ls *labelScope) declare(b *block, s *LabeledStmt) *label {
labels = make(map[string]*label)
ls.labels = labels
} else if alt := labels[name]; alt != nil {
- ls.err(s.Label.Pos(), "label %s already defined at %s", name, alt.lstmt.Label.Pos().String())
+ ls.errf(s.Label.Pos(), "label %s already defined at %s", name, alt.lstmt.Label.Pos().String())
return alt
}
l := &label{b, s, false}
@@ -188,7 +188,7 @@ func (ls *labelScope) blockBranches(parent *block, ctxt targets, lstmt *LabeledS
fwd.Target = s
l.used = true
if jumpsOverVarDecl(fwd) {
- ls.err(
+ ls.errf(
fwd.Label.Pos(),
"goto %s jumps over declaration of %s at %s",
name, String(varName), varPos,
@@ -215,13 +215,13 @@ func (ls *labelScope) blockBranches(parent *block, ctxt targets, lstmt *LabeledS
if t := ctxt.breaks; t != nil {
s.Target = t
} else {
- ls.err(s.Pos(), "break is not in a loop, switch, or select")
+ ls.errf(s.Pos(), "break is not in a loop, switch, or select")
}
case _Continue:
if t := ctxt.continues; t != nil {
s.Target = t
} else {
- ls.err(s.Pos(), "continue is not in a loop")
+ ls.errf(s.Pos(), "continue is not in a loop")
}
case _Fallthrough:
msg := "fallthrough statement out of place"
@@ -237,7 +237,7 @@ func (ls *labelScope) blockBranches(parent *block, ctxt targets, lstmt *LabeledS
break // fallthrough ok
}
}
- ls.err(s.Pos(), msg)
+ ls.errf(s.Pos(), "%s", msg)
case _Goto:
fallthrough // should always have a label
default:
@@ -258,10 +258,10 @@ func (ls *labelScope) blockBranches(parent *block, ctxt targets, lstmt *LabeledS
case *SwitchStmt, *SelectStmt, *ForStmt:
s.Target = t
default:
- ls.err(s.Label.Pos(), "invalid break label %s", name)
+ ls.errf(s.Label.Pos(), "invalid break label %s", name)
}
} else {
- ls.err(s.Label.Pos(), "break label not defined: %s", name)
+ ls.errf(s.Label.Pos(), "break label not defined: %s", name)
}
case _Continue:
@@ -271,10 +271,10 @@ func (ls *labelScope) blockBranches(parent *block, ctxt targets, lstmt *LabeledS
if t, ok := t.Stmt.(*ForStmt); ok {
s.Target = t
} else {
- ls.err(s.Label.Pos(), "invalid continue label %s", name)
+ ls.errf(s.Label.Pos(), "invalid continue label %s", name)
}
} else {
- ls.err(s.Label.Pos(), "continue label not defined: %s", name)
+ ls.errf(s.Label.Pos(), "continue label not defined: %s", name)
}
case _Goto: