]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: handle another Clang DWARF quirk
authorMatthew Dempsky <mdempsky@google.com>
Wed, 25 Nov 2015 20:40:43 +0000 (12:40 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 25 Nov 2015 21:13:41 +0000 (21:13 +0000)
Without the fix:

    $ CC=clang-3.5 ./test.bash
    misc/cgo/errors/test.bash: BUG: expected error output to contain "C.ushort" but saw:
    # command-line-arguments
    ./issue13129.go:13: cannot use int(0) (type int) as type C.unsignedshort in assignment

Fixes #13129.

Change-Id: I2c019d2d000f5bfa3e33c477e533aff97031a84f
Reviewed-on: https://go-review.googlesource.com/17207
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

misc/cgo/errors/issue13129.go [new file with mode: 0644]
misc/cgo/errors/test.bash
src/cmd/cgo/gcc.go

diff --git a/misc/cgo/errors/issue13129.go b/misc/cgo/errors/issue13129.go
new file mode 100644 (file)
index 0000000..942d2f7
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2015 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.
+
+// issue 13129: used to output error about C.unsignedshort with CC=clang
+
+package main
+
+import "C"
+
+func main() {
+       var x C.ushort
+       x = int(0) // ERROR HERE
+}
index a061419992fa32efd44b55fc15563ab40f9a15c0..d15c9e113d33ad57a75ade13c0cbb2cb5d3c3641 100755 (executable)
@@ -11,6 +11,12 @@ check() {
                echo 1>&2 misc/cgo/errors/test.bash: BUG: cannot find ERROR HERE in $file
                exit 1
        fi
+       expect $file $file:$line:
+}
+
+expect() {
+       file=$1
+       error=$2
        if go build $file >errs 2>&1; then
                echo 1>&2 misc/cgo/errors/test.bash: BUG: expected cgo to fail but it succeeded
                exit 1
@@ -19,8 +25,8 @@ check() {
                echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error output but saw none
                exit 1
        fi
-       if ! fgrep $file:$line: errs >/dev/null 2>&1; then
-               echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error on line $line but saw:
+       if ! fgrep $error errs >/dev/null 2>&1; then
+               echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error output to contain \"$error\" but saw:
                cat 1>&2 errs
                exit 1
        fi
@@ -33,6 +39,7 @@ check issue7757.go
 check issue8442.go
 check issue11097a.go
 check issue11097b.go
+expect issue13129.go C.ushort
 
 if ! go run ptr.go; then
        exit 1
index ed121dad810662c87d30899202b288417ca64a99..af2456e421bbaf429e0d060c038effca6ee02e39 100644 (file)
@@ -1314,6 +1314,7 @@ var dwarfToName = map[string]string{
        "long unsigned int":      "ulong",
        "unsigned int":           "uint",
        "short unsigned int":     "ushort",
+       "unsigned short":         "ushort", // Used by Clang; issue 13129.
        "short int":              "short",
        "long long int":          "longlong",
        "long long unsigned int": "ulonglong",