aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-02-28 14:09:47 -0800
committerMatthew Dempsky <mdempsky@google.com>2022-03-01 19:45:44 +0000
commit302af4be8e27b55b7a8572adece64e2271d09b97 (patch)
treeaec8a8e2c3195abd5e06d3e592d61c6e5ce13b49 /src/cmd/compile/internal/noder
parente24977d23103fc969da9b1173b5e629870628185 (diff)
downloadgo-302af4be8e27b55b7a8572adece64e2271d09b97.tar.xz
cmd/compile: remove -G flag
Post 1.18, we're committed to types2 as cmd/compile's type checker. Change-Id: I30d2dd2b2ba62832fcdcaeb996fcbc8a4a05d591 Reviewed-on: https://go-review.googlesource.com/c/go/+/388535 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/irgen.go9
-rw-r--r--src/cmd/compile/internal/noder/noder.go109
2 files changed, 3 insertions, 115 deletions
diff --git a/src/cmd/compile/internal/noder/irgen.go b/src/cmd/compile/internal/noder/irgen.go
index 52224c4046..993c254218 100644
--- a/src/cmd/compile/internal/noder/irgen.go
+++ b/src/cmd/compile/internal/noder/irgen.go
@@ -6,7 +6,6 @@ package noder
import (
"fmt"
- "os"
"cmd/compile/internal/base"
"cmd/compile/internal/dwarfgen"
@@ -77,10 +76,6 @@ func checkFiles(noders []*noder) (posMap, *types2.Package, *types2.Info) {
func check2(noders []*noder) {
m, pkg, info := checkFiles(noders)
- if base.Flag.G < 2 {
- os.Exit(0)
- }
-
g := irgen{
target: typecheck.Target,
self: pkg,
@@ -90,10 +85,6 @@ func check2(noders []*noder) {
typs: make(map[types2.Type]*types.Type),
}
g.generate(noders)
-
- if base.Flag.G < 3 {
- os.Exit(0)
- }
}
// Information about sub-dictionary entries in a dictionary
diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go
index b36db67a50..2cd7218c55 100644
--- a/src/cmd/compile/internal/noder/noder.go
+++ b/src/cmd/compile/internal/noder/noder.go
@@ -9,7 +9,6 @@ import (
"fmt"
"go/constant"
"go/token"
- "internal/buildcfg"
"os"
"path/filepath"
"runtime"
@@ -31,13 +30,7 @@ import (
func LoadPackage(filenames []string) {
base.Timer.Start("fe", "parse")
- // -G=3 and unified expect generics syntax, but -G=0 does not.
- supportsGenerics := base.Flag.G != 0 || buildcfg.Experiment.Unified
-
- mode := syntax.CheckBranches
- if supportsGenerics {
- mode |= syntax.AllowGenerics
- }
+ mode := syntax.CheckBranches | syntax.AllowGenerics
// Limit the number of simultaneously open files.
sem := make(chan struct{}, runtime.GOMAXPROCS(0)+10)
@@ -85,104 +78,8 @@ func LoadPackage(filenames []string) {
return
}
- 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
- }
-
- if base.SyntaxErrors() != 0 {
- base.ErrorExit()
- }
- types.CheckDclstack()
-
- for _, p := range noders {
- p.processPragmas()
- }
-
- // Typecheck.
- types.LocalPkg.Height = myheight
- typecheck.DeclareUniverse()
- typecheck.TypecheckAllowed = true
-
- // Process top-level declarations in phases.
-
- // Phase 1: const, type, and names and types of funcs.
- // This will gather all the information about types
- // and methods but doesn't depend on any of it.
- //
- // We also defer type alias declarations until phase 2
- // to avoid cycles like #18640.
- // TODO(gri) Remove this again once we have a fix for #25838.
- //
- // Phase 2: Variable assignments.
- // To check interface assignments, depends on phase 1.
-
- // Don't use range--typecheck can add closures to Target.Decls.
- for phase, name := range []string{"top1", "top2"} {
- base.Timer.Start("fe", "typecheck", name)
- for i := 0; i < len(typecheck.Target.Decls); i++ {
- n := typecheck.Target.Decls[i]
- op := n.Op()
-
- // Closure function declarations are typechecked as part of the
- // closure expression.
- if fn, ok := n.(*ir.Func); ok && fn.OClosure != nil {
- continue
- }
-
- // We don't actually add ir.ODCL nodes to Target.Decls. Make sure of that.
- if op == ir.ODCL {
- base.FatalfAt(n.Pos(), "unexpected top declaration: %v", op)
- }
-
- // Identify declarations that should be deferred to the second
- // iteration.
- late := op == ir.OAS || op == ir.OAS2 || op == ir.ODCLTYPE && n.(*ir.Decl).X.Alias()
-
- if late == (phase == 1) {
- typecheck.Target.Decls[i] = typecheck.Stmt(n)
- }
- }
- }
-
- // Phase 3: Type check function bodies.
- // Don't use range--typecheck can add closures to Target.Decls.
- base.Timer.Start("fe", "typecheck", "func")
- for i := 0; i < len(typecheck.Target.Decls); i++ {
- if fn, ok := typecheck.Target.Decls[i].(*ir.Func); ok {
- if base.Flag.W > 1 {
- s := fmt.Sprintf("\nbefore typecheck %v", fn)
- ir.Dump(s, fn)
- }
- typecheck.FuncBody(fn)
- if base.Flag.W > 1 {
- s := fmt.Sprintf("\nafter typecheck %v", fn)
- ir.Dump(s, fn)
- }
- }
- }
-
- // Phase 4: Check external declarations.
- // TODO(mdempsky): This should be handled when type checking their
- // corresponding ODCL nodes.
- base.Timer.Start("fe", "typecheck", "externdcls")
- for i, n := range typecheck.Target.Externs {
- if n.Op() == ir.ONAME {
- typecheck.Target.Externs[i] = typecheck.Expr(typecheck.Target.Externs[i])
- }
- }
-
- // Phase 5: With all user code type-checked, it's now safe to verify map keys.
- // With all user code typechecked, it's now safe to verify unused dot imports.
- typecheck.CheckMapKeys()
- CheckDotImports()
- base.ExitIfErrors()
+ // Use types2 to type-check and generate IR.
+ check2(noders)
}
func (p *noder) errorAt(pos syntax.Pos, format string, args ...interface{}) {