1
0
mirror of https://github.com/golang/go synced 2024-11-15 12:20:32 -07:00
go/misc
Andrew Gerrand 265ff83af6 [release-branch.go1.2] cmd/cgo: stop using compiler error message text to analyze C names
««« CL 15070043 / 90a628ac54ed
cmd/cgo: stop using compiler error message text to analyze C names

The old approach to determining whether "name" was a type, constant,
or expression was to compile the C program

        name;

and scan the errors and warnings generated by the compiler.
This requires looking for specific substrings in the errors and warnings,
which ties the implementation to specific compiler versions.
As compilers change their errors or drop warnings, cgo breaks.
This happens slowly but it does happen.
Clang in particular (now required on OS X) has a significant churn rate.

The new approach compiles a slightly more complex program
that is either valid C or not valid C depending on what kind of
thing "name" is. It uses only the presence or absence of an error
message on a particular line, not the error text itself. The program is:

        // error if and only if name is undeclared
        void f1(void) { typeof(name) *x; }

        // error if and only if name is not a type
        void f2(void) { name *x; }

        // error if and only if name is not an integer constant
        void f3(void) { enum { x = (name)*1 }; }

I had not been planning to do this until Go 1.3, because it is a
non-trivial change, but it fixes a real Xcode 5 problem in Go 1.2,
and the new code is easier to understand than the old code.
It should be significantly more robust.

Fixes #6596.
Fixes #6612.

R=golang-dev, r, james, iant
CC=golang-dev
https://golang.org/cl/15070043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/20060044
2013-11-01 11:05:17 +11:00
..
arm
bash
bbedit misc/{bbedit|IntelliJIDEA|kate}: add missing delete predeclared identifier 2013-06-24 13:17:56 -07:00
cgo [release-branch.go1.2] cmd/cgo: stop using compiler error message text to analyze C names 2013-11-01 11:05:17 +11:00
chrome/gophertool gophertool: fix links 2012-10-22 01:05:21 +08:00
dashboard/codereview misc/dashboard/app, misc/dashboard/builder: delete from main repo; part of move to go.tools 2013-08-01 13:27:27 +10:00
dist [release-branch.go1.2] misc/dist: build race packages when os suffix present 2013-11-01 10:50:00 +11:00
emacs misc/emacs: send correct content-length to the playground 2013-10-10 16:49:19 -04:00
fraise
git misc/git: add gofmt git pre-commit hook 2012-11-15 19:58:49 +01:00
goplay misc/goplay: use go run x.go instead of go build x.go 2013-07-12 09:41:10 +10:00
IntelliJIDEA misc/{bbedit|IntelliJIDEA|kate}: add missing delete predeclared identifier 2013-06-24 13:17:56 -07:00
kate misc/{bbedit|IntelliJIDEA|kate}: add missing delete predeclared identifier 2013-06-24 13:17:56 -07:00
linkcheck misc: add linkcheck tool 2013-08-29 12:08:11 -07:00
notepadplus misc/notepadplus: fix some number syntax highlight issue 2013-09-23 11:35:17 +10:00
swig cmd/go: add any .c/.cc files to the SWIG shared library 2013-10-09 10:35:46 -07:00
vim misc/vim: complete packages in src directory 2013-10-11 11:30:03 +11:00
xcode misc/xcode: use xcode-select to determine path 2013-08-20 20:48:29 +10:00
zsh misc: update zsh completion 2013-04-07 04:11:12 +08:00
benchcmp misc/benchcmp: show byte allocation statistics 2012-12-22 14:51:16 -05:00
pprof misc/pprof: support block profile 2013-09-23 14:15:20 -07:00