mirror of https://github.com/golang/go.git
cmd/gc: silence assignment errors to undefined symbols
Fixes #6406. R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/46900043
This commit is contained in:
parent
880442f110
commit
f2e94b58a0
|
|
@ -2680,6 +2680,11 @@ checkassign(Node *n)
|
||||||
n->etype = 1;
|
n->etype = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// have already complained about n being undefined
|
||||||
|
if(n->op == ONONAME)
|
||||||
|
return;
|
||||||
|
|
||||||
yyerror("cannot assign to %N", n);
|
yyerror("cannot assign to %N", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
// errorcheck
|
||||||
|
|
||||||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
s = "bob" // ERROR "undefined.*s"
|
||||||
|
_ = s // ERROR "undefined.*s"
|
||||||
|
}
|
||||||
|
|
@ -14,5 +14,5 @@ func mine(int b) int { // ERROR "undefined.*b"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
mine() // GCCGO_ERROR "not enough arguments"
|
mine() // GCCGO_ERROR "not enough arguments"
|
||||||
c = mine() // ERROR "undefined.*c|not enough arguments" "cannot assign to c"
|
c = mine() // ERROR "undefined.*c|not enough arguments"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue