[dev.typeparams] cmd/compile: enable parsing of generic code with new -G flag

Providing the -G flag instructs the compiler to accept type parameters.
For now, the compiler only parses such files and then exits.

Added a new test directory (test/typeparam) and initial test case.

Port from dev.go2go branch.

Change-Id: Ic11e33a9d5f012f8def0bdae205043659562ac73
Reviewed-on: https://go-review.googlesource.com/c/go/+/261660
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2020-10-12 16:19:49 -07:00
parent 7668f02dec
commit 48755e06aa
4 changed files with 77 additions and 5 deletions

View file

@ -216,6 +216,7 @@ func Main(archInit func(*Arch)) {
objabi.Flagcount("C", "disable printing of columns in error messages", &Debug['C']) // TODO(gri) remove eventually
flag.StringVar(&localimport, "D", "", "set relative `path` for local imports")
objabi.Flagcount("E", "debug symbol export", &Debug['E'])
objabi.Flagcount("G", "accept generic code", &Debug['G'])
objabi.Flagfn1("I", "add `directory` to import search path", addidir)
objabi.Flagcount("K", "debug missing line numbers", &Debug['K'])
objabi.Flagcount("L", "show full file names in error messages", &Debug['L'])
@ -571,9 +572,16 @@ func Main(archInit func(*Arch)) {
loadsys()
timings.Start("fe", "parse")
lines := parseFiles(flag.Args())
lines := parseFiles(flag.Args(), Debug['G'] != 0)
timings.Stop()
timings.AddEvent(int64(lines), "lines")
if Debug['G'] != 0 {
// can only parse generic code for now
if nerrors+nsavederrors != 0 {
errorexit()
}
return
}
finishUniverse()