cmd/compile: add -lang flag to specify language version

The default language version is the current one.

For testing purposes, added a check that type aliases require version
go1.9. There is no consistent support for changes made before 1.12.

Updates #28221

Change-Id: Ia1ef63fff911d5fd29ef79d5fa4e20cfd945feb7
Reviewed-on: https://go-review.googlesource.com/c/144340
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Ian Lance Taylor 2018-10-24 15:49:32 -07:00
parent d1836e629f
commit 2e9f0817f0
5 changed files with 137 additions and 2 deletions

View file

@ -417,8 +417,11 @@ func (p *noder) typeDecl(decl *syntax.TypeDecl) *Node {
param.Pragma = 0
}
return p.nod(decl, ODCLTYPE, n, nil)
nod := p.nod(decl, ODCLTYPE, n, nil)
if param.Alias && !langSupported(1, 9) {
yyerrorl(nod.Pos, "type aliases only supported as of -lang=go1.9")
}
return nod
}
func (p *noder) declNames(names []*syntax.Name) []*Node {