1
0
mirror of https://github.com/golang/go synced 2024-09-24 09:20:15 -06:00

cmd/gc: more robust checking of OIND nodes.

Fixes #4610.

R=golang-dev, remyoudompheng, rsc
CC=golang-dev, nigeltao
https://golang.org/cl/7058057
This commit is contained in:
Daniel Morsing 2013-01-18 22:46:10 +01:00
parent b62847000b
commit c0d9bf5650
2 changed files with 23 additions and 3 deletions

View File

@ -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;

View File

@ -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"
}