summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevon H. O'Dell <devon.odell@gmail.com>2010-01-13 10:25:28 -0800
committerDevon H. O'Dell <devon.odell@gmail.com>2010-01-13 10:25:28 -0800
commit5969137c8befe9ed723b5f63136e6d5d11e1f31e (patch)
treeefa9aea9f37295c388df2d8c8e3260bba03bddac
parent6c1160eaf0df37496e9e37c963f0b3bb417621f0 (diff)
downloadgo-5969137c8befe9ed723b5f63136e6d5d11e1f31e.tar.gz
cgo: handle C99 bool type
Fixes issue 307. R=rsc CC=golang-dev http://codereview.appspot.com/186073 Committer: Russ Cox <rsc@golang.org>
-rw-r--r--src/cmd/cgo/gcc.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go
index dd6223ea7..4f65a1afb 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -329,6 +329,7 @@ type typeConv struct {
typedef map[string]ast.Expr
// Predeclared types.
+ bool ast.Expr
byte ast.Expr // denotes padding
int8, int16, int32, int64 ast.Expr
uint8, uint16, uint32, uint64, uintptr ast.Expr
@@ -346,6 +347,7 @@ func (c *typeConv) Init(ptrSize int64) {
c.ptrSize = ptrSize
c.m = make(map[dwarf.Type]*Type)
c.typedef = make(map[string]ast.Expr)
+ c.bool = c.Ident("bool")
c.byte = c.Ident("byte")
c.int8 = c.Ident("int8")
c.int16 = c.Ident("int16")
@@ -443,6 +445,10 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type {
gt.Elt = sub.Go
t.C = fmt.Sprintf("typeof(%s[%d])", sub.C, dt.Count)
+ case *dwarf.BoolType:
+ t.Go = c.bool
+ t.Align = c.ptrSize
+
case *dwarf.CharType:
if t.Size != 1 {
fatal("unexpected: %d-byte char type - %s", t.Size, dtype)
@@ -613,7 +619,7 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type {
}
switch dtype.(type) {
- case *dwarf.AddrType, *dwarf.CharType, *dwarf.IntType, *dwarf.FloatType, *dwarf.UcharType, *dwarf.UintType:
+ case *dwarf.AddrType, *dwarf.BoolType, *dwarf.CharType, *dwarf.IntType, *dwarf.FloatType, *dwarf.UcharType, *dwarf.UintType:
s := dtype.Common().Name
if s != "" {
if ss, ok := cnameMap[s]; ok {