diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index d77dd878cb..d00e436719 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -482,9 +482,12 @@ reswitch: n->left = N; goto ret; } - if((top & (Erv | Etop)) && !isptr[t->etype]) { - yyerror("invalid indirect of %lN", n->left); - goto error; + if(!isptr[t->etype]) { + if(top & (Erv | Etop)) { + yyerror("invalid indirect of %lN", n->left); + goto error; + } + goto ret; } ok |= Erv; n->type = t->type; diff --git a/test/fixedbugs/issue4610.go b/test/fixedbugs/issue4610.go new file mode 100644 index 0000000000..bc6bfe7906 --- /dev/null +++ b/test/fixedbugs/issue4610.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2012 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 + +type bar struct { + x int +} + +func main() { + var foo bar + _ = &foo{} // ERROR "is not a type" +} +