// void __cgo_f_xxx_4(void) { static const double __cgo_undefined__4 = (name); }
// #line xxx "not-str-lit"
// void __cgo_f_xxx_5(void) { static const char __cgo_undefined__5[] = (name); }
- // #line xxx "not-signed-int-const"
- // #if 0 < -(name)
- // #line xxx "not-signed-int-const"
- // #error found unsigned int
- // #endif
//
// If we see an error at not-declared:xxx, the corresponding name is not declared.
// If we see an error at not-type:xxx, the corresponding name is a type.
// If we see an error at not-int-const:xxx, the corresponding name is not an integer constant.
// If we see an error at not-num-const:xxx, the corresponding name is not a number constant.
// If we see an error at not-str-lit:xxx, the corresponding name is not a string literal.
- // If we see an error at not-signed-int-const:xxx, the corresponding name is not a signed integer literal.
//
// The specific input forms are chosen so that they are valid C syntax regardless of
// whether name denotes a type or an expression.
"#line %d \"not-num-const\"\n"+
"void __cgo_f_%d_4(void) { static const double __cgo_undefined__4 = (%s); }\n"+
"#line %d \"not-str-lit\"\n"+
- "void __cgo_f_%d_5(void) { static const char __cgo_undefined__5[] = (%s); }\n"+
- "#line %d \"not-signed-int-const\"\n"+
- "#if 0 < (%s)\n"+
- "#line %d \"not-signed-int-const\"\n"+
- "#error found unsigned int\n"+
- "#endif\n",
+ "void __cgo_f_%d_5(void) { static const char __cgo_undefined__5[] = (%s); }\n",
i+1, i+1, n.C,
i+1, i+1, n.C,
i+1, i+1, n.C,
i+1, i+1, n.C,
i+1, i+1, n.C,
- i+1, n.C, i+1,
)
}
fmt.Fprintf(&b, "#line 1 \"completed\"\n"+
notNumConst
notStrLiteral
notDeclared
- notSignedIntConst
)
sawUnmatchedErrors := false
for _, line := range strings.Split(stderr, "\n") {
sniff[i] |= notNumConst
case "not-str-lit":
sniff[i] |= notStrLiteral
- case "not-signed-int-const":
- sniff[i] |= notSignedIntConst
default:
if isError {
sawUnmatchedErrors = true
}
for i, n := range names {
- switch sniff[i] &^ notSignedIntConst {
+ switch sniff[i] {
default:
var tpos token.Pos
for _, ref := range f.Ref {
}
error_(tpos, "could not determine kind of name for C.%s", fixGo(n.Go))
case notStrLiteral | notType:
- if sniff[i]¬SignedIntConst != 0 {
- n.Kind = "uconst"
- } else {
- n.Kind = "iconst"
- }
+ n.Kind = "iconst"
case notIntConst | notStrLiteral | notType:
n.Kind = "fconst"
case notIntConst | notNumConst | notType:
b.WriteString("#line 1 \"cgo-dwarf-inference\"\n")
for i, n := range names {
fmt.Fprintf(&b, "__typeof__(%s) *__cgo__%d;\n", n.C, i)
- if n.Kind == "iconst" || n.Kind == "uconst" {
+ if n.Kind == "iconst" {
fmt.Fprintf(&b, "enum { __cgo_enum__%d = %s };\n", i, n.C)
}
}
// so we can read them out of the object file.
fmt.Fprintf(&b, "long long __cgodebug_ints[] = {\n")
for _, n := range names {
- if n.Kind == "iconst" || n.Kind == "uconst" {
+ if n.Kind == "iconst" {
fmt.Fprintf(&b, "\t%s,\n", n.C)
} else {
fmt.Fprintf(&b, "\t0,\n")
switch n.Kind {
case "iconst":
if i < len(ints) {
- n.Const = fmt.Sprintf("%#x", ints[i])
- }
- case "uconst":
- if i < len(ints) {
- n.Const = fmt.Sprintf("%#x", uint64(ints[i]))
+ if _, ok := types[i].(*dwarf.UintType); ok {
+ n.Const = fmt.Sprintf("%#x", uint64(ints[i]))
+ } else {
+ n.Const = fmt.Sprintf("%#x", ints[i])
+ }
}
case "fconst":
if i < len(floats) {
Mangle string // name used in generated Go
C string // name used in C
Define string // #define expansion
- Kind string // "iconst", "uconst", "fconst", "sconst", "type", "var", "fpvar", "func", "not-type"
+ Kind string // "iconst", "fconst", "sconst", "type", "var", "fpvar", "func", "not-type"
Type *Type // the type of xxx
FuncType *FuncType
AddError bool
return n.Kind == "var" || n.Kind == "fpvar"
}
-// IsConst reports whether Kind is either "iconst", "uconst", "fconst" or "sconst"
+// IsConst reports whether Kind is either "iconst", "fconst" or "sconst"
func (n *Name) IsConst() bool {
return strings.HasSuffix(n.Kind, "const")
}