Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-fmt does not know about gccgo __asm__ extension #1981

Closed
gopherbot opened this issue Jun 20, 2011 · 3 comments
Closed

go-fmt does not know about gccgo __asm__ extension #1981

gopherbot opened this issue Jun 20, 2011 · 3 comments

Comments

@gopherbot
Copy link
Contributor

by lockalsash:

What steps will reproduce the problem?
1. cat hello.go
package main

func test1() __asm__ ("test1");
func test2() int __asm__ ("test2");
func main() {}

2. gofmt -s -w hello.go 

What is the expected output?
Formatted code

What do you see instead?
hello.go:3:22: expected ';', found '('
hello.go:4:18: expected ';', found 'IDENT' __asm__

Which compiler are you using (5g, 6g, 8g, gccgo)?
gccgo

Which operating system are you using?
Ubuntu 11.04

Which revision are you using?  (hg identify)
weekly.2011-06-16 8791+
@rsc
Copy link
Contributor

rsc commented Jun 20, 2011

Comment 1:

Your hello.go is not a valid Go program, so gofmt correctly rejects it.

Owner changed to @griesemer.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Contributor Author

Comment 2 by lockalsash:

This program is completely valid for gccgo. AFAIK the only way to call C functions from
gccgo is to use __asm__ extension.

@rsc
Copy link
Contributor

rsc commented Jun 20, 2011

Comment 3:

Yes, but gofmt only claims to work on Go programs
as defined by the Go specification at
http://golang.org/doc/go_spec.html, and the
program is definitely not valid according to the spec.
Gccgo accepts an extended version of Go, just like
gcc accepts an extended version of C.
In both cases, tools that work on the specified
language may not work on programs using the
non-standard GNU extensions.
It would be good to figure out a way to make gofmt
run on typical programs used with gccgo, but that
way cannot be to let these annotations propagate.
Another way, for example, would be to say that
func test1()
has the right default, and if you want to do more you
write a C program.  In the long term yet another way
is that cgo should be made to work with gccgo.
Russ

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants