aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/cgo/ast.go3
-rw-r--r--src/cmd/cgo/gcc.go2
-rw-r--r--src/cmd/cgo/main.go4
3 files changed, 5 insertions, 4 deletions
diff --git a/src/cmd/cgo/ast.go b/src/cmd/cgo/ast.go
index c342a01783..06058cb570 100644
--- a/src/cmd/cgo/ast.go
+++ b/src/cmd/cgo/ast.go
@@ -66,7 +66,6 @@ func (f *File) ParseGo(name string, src []byte) {
f.Package = ast1.Name.Name
f.Name = make(map[string]*Name)
f.NamePos = make(map[*Name]token.Pos)
- f.Consts = make(map[string]bool)
// In ast1, find the import "C" line and get any extra C preamble.
sawC := false
@@ -198,7 +197,7 @@ func (f *File) saveExprs(x interface{}, context astContext) {
vs := spec.(*ast.ValueSpec)
if vs.Type == nil {
for _, name := range spec.(*ast.ValueSpec).Names {
- f.Consts[name.Name] = true
+ consts[name.Name] = true
}
}
}
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go
index fdd34f560f..56a4775746 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -1233,7 +1233,7 @@ func (p *Package) isConst(f *File, x ast.Expr) bool {
strings.HasPrefix(x.Name, "_Ciconst_") ||
strings.HasPrefix(x.Name, "_Cfconst_") ||
strings.HasPrefix(x.Name, "_Csconst_") ||
- f.Consts[x.Name]
+ consts[x.Name]
case *ast.UnaryExpr:
return p.isConst(f, x.X)
case *ast.BinaryExpr:
diff --git a/src/cmd/cgo/main.go b/src/cmd/cgo/main.go
index a317a1494d..e28a57b148 100644
--- a/src/cmd/cgo/main.go
+++ b/src/cmd/cgo/main.go
@@ -62,9 +62,11 @@ type File struct {
Name map[string]*Name // map from Go name to Name
NamePos map[*Name]token.Pos // map from Name to position of the first reference
Edit *edit.Buffer
- Consts map[string]bool // untyped constants
}
+// Untyped constants in the current package.
+var consts = make(map[string]bool)
+
func (f *File) offset(p token.Pos) int {
return fset.Position(p).Offset
}