aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/noder.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/noder/noder.go')
-rw-r--r--src/cmd/compile/internal/noder/noder.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go
index 5b5b09cb2d..1c38f1a934 100644
--- a/src/cmd/compile/internal/noder/noder.go
+++ b/src/cmd/compile/internal/noder/noder.go
@@ -30,6 +30,9 @@ func LoadPackage(filenames []string) {
base.Timer.Start("fe", "parse")
mode := syntax.CheckBranches
+ if base.Flag.G != 0 {
+ mode |= syntax.AllowGenerics
+ }
// Limit the number of simultaneously open files.
sem := make(chan struct{}, runtime.GOMAXPROCS(0)+10)
@@ -65,10 +68,16 @@ func LoadPackage(filenames []string) {
for e := range p.err {
p.errorAt(e.Pos, "%s", e.Msg)
}
- lines += p.file.Lines
+ lines += p.file.EOF.Line()
}
base.Timer.AddEvent(int64(lines), "lines")
+ if base.Flag.G != 0 {
+ // Use types2 to type-check and possibly generate IR.
+ check2(noders)
+ return
+ }
+
for _, p := range noders {
p.node()
p.file = nil // release memory
@@ -1031,8 +1040,7 @@ func (p *noder) stmtFall(stmt syntax.Stmt, fallOK bool) ir.Node {
case *syntax.DeclStmt:
return ir.NewBlockStmt(src.NoXPos, p.decls(stmt.DeclList))
case *syntax.AssignStmt:
- if stmt.Rhs == syntax.ImplicitOne {
- one := constant.MakeInt64(1)
+ if stmt.Rhs == nil {
pos := p.pos(stmt)
n := ir.NewAssignOpStmt(pos, p.binOp(stmt.Op), p.expr(stmt.Lhs), ir.NewBasicLit(pos, one))
n.IncDec = true