From c0d9bf5650361191f5e86c4a31176a01a9c2867b Mon Sep 17 00:00:00 2001 From: Daniel Morsing Date: Fri, 18 Jan 2013 22:46:10 +0100 Subject: [PATCH] cmd/gc: more robust checking of OIND nodes. Fixes #4610. R=golang-dev, remyoudompheng, rsc CC=golang-dev, nigeltao https://golang.org/cl/7058057 --- src/cmd/gc/typecheck.c | 9 ++++++--- test/fixedbugs/issue4610.go | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 test/fixedbugs/issue4610.go 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" +} +