OSDN Git Service

libgo: Update to weekly.2011-11-01.
[pf3gnuchains/gcc-fork.git] / libgo / go / go / parser / parser.go
index be82b2f..e2c9441 100644 (file)
@@ -434,7 +434,9 @@ func (p *parser) parseLhsList() []ast.Expr {
        switch p.tok {
        case token.DEFINE:
                // lhs of a short variable declaration
-               p.shortVarDecl(p.makeIdentList(list))
+               // but doesn't enter scope until later:
+               // caller must call p.shortVarDecl(p.makeIdentList(list))
+               // at appropriate time.
        case token.COLON:
                // lhs of a label declaration or a communication clause of a select
                // statement (parseLhsList is not called when parsing the case clause
@@ -1398,6 +1400,9 @@ func (p *parser) parseSimpleStmt(mode int) (ast.Stmt, bool) {
                } else {
                        y = p.parseRhsList()
                }
+               if tok == token.DEFINE {
+                       p.shortVarDecl(p.makeIdentList(x))
+               }
                return &ast.AssignStmt{x, pos, tok, y}, isRange
        }
 
@@ -1722,6 +1727,9 @@ func (p *parser) parseCommClause() *ast.CommClause {
                                }
                                p.next()
                                rhs = p.parseRhs()
+                               if tok == token.DEFINE && lhs != nil {
+                                       p.shortVarDecl(p.makeIdentList(lhs))
+                               }
                        } else {
                                // rhs must be single receive operation
                                if len(lhs) > 1 {
@@ -1909,7 +1917,7 @@ func parseImportSpec(p *parser, doc *ast.CommentGroup, _ int) ast.Spec {
        p.expectSemi() // call before accessing p.linecomment
 
        // collect imports
-       spec := &ast.ImportSpec{doc, ident, path, p.lineComment}
+       spec := &ast.ImportSpec{doc, ident, path, p.lineComment, token.NoPos}
        p.imports = append(p.imports, spec)
 
        return spec