From 3fd3171c2c2b3f55cb9692b45f2ebb842e9b0b42 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 9 Feb 2017 16:00:23 -0800 Subject: cmd/compile/internal/syntax: removed gcCompat code needed to pass orig. tests The gcCompat mode was introduced to match the new parser's node position setup exactly with the positions used by the original parser. Some of the gcCompat adjustments were required to satisfy syntax error test cases, and the rest were required to make toolstash cmp pass. This change removes the former gcCompat adjustments and instead adjusts the respective test cases as necessary. In some cases this makes the error lines consistent with the ones reported by gccgo. Where it has changed, the position associated with a given syntactic construct is the position (line/col number) of the left-most token belonging to the construct. Change-Id: I5b60c00c5999a895c4d6d6e9b383c6405ccf725c Reviewed-on: https://go-review.googlesource.com/36695 Run-TryBot: Robert Griesemer TryBot-Result: Gobot Gobot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/syntax/parser.go | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'src/cmd/compile/internal/syntax/parser.go') diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index c1faa27894..a11be9717c 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -358,7 +358,7 @@ func (p *parser) importDecl(group *Group) Decl { d.LocalPkgName = n p.next() } - if p.tok == _Literal && (gcCompat || p.kind == StringLit) { + if p.tok == _Literal && p.kind == StringLit { d.Path = p.oliteral() } else { p.syntax_error("missing import path; require quoted string") @@ -637,16 +637,13 @@ func (p *parser) callStmt() *CallStmt { s := new(CallStmt) s.init(p) - s.Tok = p.tok + s.Tok = p.tok // _Defer or _Go p.next() x := p.pexpr(p.tok == _Lparen) // keep_parens so we can report error below switch x := x.(type) { case *CallExpr: s.Call = x - if gcCompat { - s.node = x.node - } case *ParenExpr: p.error(fmt.Sprintf("expression in %s must not be parenthesized", s.Tok)) // already progressed, no need to advance @@ -1127,9 +1124,6 @@ func (p *parser) structType() *StructType { break } } - if gcCompat { - typ.init(p) - } p.want(_Rbrace) return typ @@ -1154,9 +1148,6 @@ func (p *parser) interfaceType() *InterfaceType { break } } - if gcCompat { - typ.init(p) - } p.want(_Rbrace) return typ @@ -1554,8 +1545,7 @@ func (p *parser) simpleStmt(lhs Expr, rangeOk bool) SimpleStmt { return p.newAssignStmt(0, lhs, p.exprList()) case _Define: - var n node - n.init(p) + pos := p.pos() p.next() if rangeOk && p.got(_Range) { @@ -1580,9 +1570,7 @@ func (p *parser) simpleStmt(lhs Expr, rangeOk bool) SimpleStmt { } as := p.newAssignStmt(Def, lhs, rhs) - if gcCompat { - as.node = n - } + as.pos = pos // TODO(gri) pass this into newAssignStmt return as default: @@ -1856,9 +1844,6 @@ func (p *parser) caseClause() *CaseClause { p.advance(_Case, _Default, _Rbrace) } - if gcCompat { - c.init(p) - } p.want(_Colon) c.Body = p.stmtList() -- cgit v1.3