diff options
author | Ian Lance Taylor <iant@golang.org> | 2023-10-20 10:11:48 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2024-02-02 15:03:47 -0800 |
commit | e52d31804a910642c9817bdd400c290a593c98ef (patch) | |
tree | 9c112848def6016f47adb1986022989763d0a594 /libgo | |
parent | fbb569315a291d2d5b32ad0fdaf0c42da9f5e93b (diff) | |
download | gcc-e52d31804a910642c9817bdd400c290a593c98ef.zip gcc-e52d31804a910642c9817bdd400c290a593c98ef.tar.gz gcc-e52d31804a910642c9817bdd400c290a593c98ef.tar.bz2 |
compiler: export the type "any" as a builtin
Otherwise we can't tell the difference between builtin type "any" and
a locally defined type "any".
This will require updates to the gccgo export data parsers in the main
Go repo and the x/tools repo. These updates are https://go.dev/cl/537195
and https://go.dev/cl/537215.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536715
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/go/internal/gccgoimporter/parser.go | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/libgo/go/go/internal/gccgoimporter/parser.go b/libgo/go/go/internal/gccgoimporter/parser.go index 48335fa..2161df7 100644 --- a/libgo/go/go/internal/gccgoimporter/parser.go +++ b/libgo/go/go/internal/gccgoimporter/parser.go @@ -187,7 +187,6 @@ func (p *parser) parseQualifiedNameStr(unquotedName string) (pkgpath, name strin // getPkg returns the package for a given path. If the package is // not found but we have a package name, create the package and // add it to the p.imports map. -// func (p *parser) getPkg(pkgpath, name string) *types.Package { // package unsafe is not in the imports map - handle explicitly if pkgpath == "unsafe" { @@ -904,6 +903,7 @@ const ( gccgoBuiltinERROR = 19 gccgoBuiltinBYTE = 20 gccgoBuiltinRUNE = 21 + gccgoBuiltinANY = 22 ) func lookupBuiltinType(typ int) types.Type { @@ -928,13 +928,13 @@ func lookupBuiltinType(typ int) types.Type { gccgoBuiltinERROR: types.Universe.Lookup("error").Type(), gccgoBuiltinBYTE: types.Universe.Lookup("byte").Type(), gccgoBuiltinRUNE: types.Universe.Lookup("rune").Type(), + gccgoBuiltinANY: types.Universe.Lookup("any").Type(), }[typ] } // Type = "<" "type" ( "-" int | int [ TypeSpec ] ) ">" . // // parseType updates the type map to t for all type numbers n. -// func (p *parser) parseType(pkg *types.Package, n ...any) types.Type { p.expect('<') t, _ := p.parseTypeAfterAngle(pkg, n...) @@ -1117,9 +1117,10 @@ func (p *parser) maybeCreatePackage() { } // InitDataDirective = ( "v1" | "v2" | "v3" ) ";" | -// "priority" int ";" | -// "init" { PackageInit } ";" | -// "checksum" unquotedString ";" . +// +// "priority" int ";" | +// "init" { PackageInit } ";" | +// "checksum" unquotedString ";" . func (p *parser) parseInitDataDirective() { if p.tok != scanner.Ident { // unexpected token kind; panic @@ -1170,15 +1171,16 @@ func (p *parser) parseInitDataDirective() { } // Directive = InitDataDirective | -// "package" unquotedString [ unquotedString ] [ unquotedString ] ";" | -// "pkgpath" unquotedString ";" | -// "prefix" unquotedString ";" | -// "import" unquotedString unquotedString string ";" | -// "indirectimport" unquotedString unquotedstring ";" | -// "func" Func ";" | -// "type" Type ";" | -// "var" Var ";" | -// "const" Const ";" . +// +// "package" unquotedString [ unquotedString ] [ unquotedString ] ";" | +// "pkgpath" unquotedString ";" | +// "prefix" unquotedString ";" | +// "import" unquotedString unquotedString string ";" | +// "indirectimport" unquotedString unquotedstring ";" | +// "func" Func ";" | +// "type" Type ";" | +// "var" Var ";" | +// "const" Const ";" . func (p *parser) parseDirective() { if p.tok != scanner.Ident { // unexpected token kind; panic |