func issue28545G(p **C.char) {
C.issue28545F(p, -1, (0))
C.issue28545F(p, 2+3, complex(1, 1))
- C.issue28545F(p, issue28772Constant, (0))
+ C.issue28545F(p, issue28772Constant, issue28772Constant2)
}
--- /dev/null
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cgotest
+
+// Constants didn't work if defined in different source file.
+
+// #define issue28772Constant2 2
+import "C"
+
+const issue28772Constant2 = C.issue28772Constant2
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
vs := spec.(*ast.ValueSpec)
if vs.Type == nil {
for _, name := range spec.(*ast.ValueSpec).Names {
- f.Consts[name.Name] = true
+ consts[name.Name] = true
}
}
}
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:
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
}