aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2013-11-01 11:14:19 +1100
committerAndrew Gerrand <adg@golang.org>2013-11-01 11:14:19 +1100
commit407b1130cd06542bd1747227bc3f527de2880488 (patch)
tree9466adb05c1015948d03f9ae33dd44517ccae8cc
parent194b6a4bf24c77db10b6c150eb9e695032c72b34 (diff)
downloadgo-407b1130cd06542bd1747227bc3f527de2880488.tar.gz
go-407b1130cd06542bd1747227bc3f527de2880488.zip
[release-branch.go1.2] cmd/cgo: use __typeof__, -w instead of typeof, -Wno-all
««« CL 14920052 / 98840b3349f4 cmd/cgo: use __typeof__, -w instead of typeof, -Wno-all Suggested by iant in earlier CL. R=golang-dev, bradfitz, iant CC=golang-dev https://golang.org/cl/14920052 »»» R=golang-dev CC=golang-dev https://golang.org/cl/20600043
-rw-r--r--src/cmd/cgo/doc.go16
-rw-r--r--src/cmd/cgo/gcc.go14
2 files changed, 15 insertions, 15 deletions
diff --git a/src/cmd/cgo/doc.go b/src/cmd/cgo/doc.go
index 24ab61102c..605bab6d2e 100644
--- a/src/cmd/cgo/doc.go
+++ b/src/cmd/cgo/doc.go
@@ -270,13 +270,13 @@ identifiers C.foo and C.bar, cgo generates this C program:
<preamble>
#line 1 "not-declared"
- void __cgo_f_xxx_1(void) { typeof(foo) *__cgo_undefined__; }
+ void __cgo_f_xxx_1(void) { __typeof__(foo) *__cgo_undefined__; }
#line 1 "not-type"
void __cgo_f_xxx_2(void) { foo *__cgo_undefined__; }
#line 1 "not-const"
void __cgo_f_xxx_3(void) { enum { __cgo_undefined__ = (foo)*1 }; }
#line 2 "not-declared"
- void __cgo_f_xxx_1(void) { typeof(bar) *__cgo_undefined__; }
+ void __cgo_f_xxx_1(void) { __typeof__(bar) *__cgo_undefined__; }
#line 2 "not-type"
void __cgo_f_xxx_2(void) { bar *__cgo_undefined__; }
#line 2 "not-const"
@@ -300,14 +300,14 @@ that t1 is a type, v2 and v3 are variables or functions, and c4, c5,
and c6 are constants, it generates:
<preamble>
- typeof(t1) *__cgo__1;
- typeof(v2) *__cgo__2;
- typeof(v3) *__cgo__3;
- typeof(c4) *__cgo__4;
+ __typeof__(t1) *__cgo__1;
+ __typeof__(v2) *__cgo__2;
+ __typeof__(v3) *__cgo__3;
+ __typeof__(c4) *__cgo__4;
enum { __cgo_enum__4 = c4 };
- typeof(c5) *__cgo__5;
+ __typeof__(c5) *__cgo__5;
enum { __cgo_enum__5 = c5 };
- typeof(c6) *__cgo__6;
+ __typeof__(c6) *__cgo__6;
enum { __cgo_enum__6 = c6 };
long long __cgo_debug_data[] = {
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go
index 7e9a55a0c9..d31fc47f1a 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -288,7 +288,7 @@ func (p *Package) guessKinds(f *File) []*Name {
// For each name, we generate these lines, where xxx is the index in toSniff plus one.
//
// #line xxx "not-declared"
- // void __cgo_f_xxx_1(void) { typeof(name) *__cgo_undefined__; }
+ // void __cgo_f_xxx_1(void) { __typeof__(name) *__cgo_undefined__; }
// #line xxx "not-type"
// void __cgo_f_xxx_2(void) { name *__cgo_undefined__; }
// #line xxx "not-const"
@@ -309,7 +309,7 @@ func (p *Package) guessKinds(f *File) []*Name {
for i, n := range names {
fmt.Fprintf(&b, "#line %d \"not-declared\"\n"+
- "void __cgo_f_%d_1(void) { typeof(%s) *__cgo_undefined__; }\n"+
+ "void __cgo_f_%d_1(void) { __typeof__(%s) *__cgo_undefined__; }\n"+
"#line %d \"not-type\"\n"+
"void __cgo_f_%d_2(void) { %s *__cgo_undefined__; }\n"+
"#line %d \"not-const\"\n"+
@@ -406,14 +406,14 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
// for symbols in the object file, so it is not enough to print the
// preamble and hope the symbols we care about will be there.
// Instead, emit
- // typeof(names[i]) *__cgo__i;
+ // __typeof__(names[i]) *__cgo__i;
// for each entry in names and then dereference the type we
// learn for __cgo__i.
var b bytes.Buffer
b.WriteString(f.Preamble)
b.WriteString(builtinProlog)
for i, n := range names {
- fmt.Fprintf(&b, "typeof(%s) *__cgo__%d;\n", n.C, i)
+ fmt.Fprintf(&b, "__typeof__(%s) *__cgo__%d;\n", n.C, i)
if n.Kind == "const" {
fmt.Fprintf(&b, "enum { __cgo_enum__%d = %s };\n", i, n.C)
}
@@ -742,7 +742,7 @@ func gccTmp() string {
// the input.
func (p *Package) gccCmd() []string {
c := append(p.gccBaseCmd(),
- "-Wno-all", // no warnings
+ "-w", // no warnings
"-Wno-error", // warnings are not errors
"-o"+gccTmp(), // write object to tmp
"-gdwarf-2", // generate DWARF v2 debugging symbols
@@ -1082,7 +1082,7 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
sub := c.Type(dt.Type, pos)
t.Align = sub.Align
gt.Elt = sub.Go
- t.C.Set("typeof(%s[%d])", sub.C, dt.Count)
+ t.C.Set("__typeof__(%s[%d])", sub.C, dt.Count)
case *dwarf.BoolType:
t.Go = c.bool
@@ -1220,7 +1220,7 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
case "class", "union":
t.Go = c.Opaque(t.Size)
if t.C.Empty() {
- t.C.Set("typeof(unsigned char[%d])", t.Size)
+ t.C.Set("__typeof__(unsigned char[%d])", t.Size)
}
t.Align = 1 // TODO: should probably base this on field alignment.
typedef[name.Name] = t