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

cmd/api: does not handle shift by a types constant. #2907

Closed
remyoudompheng opened this issue Feb 7, 2012 · 11 comments
Closed

cmd/api: does not handle shift by a types constant. #2907

remyoudompheng opened this issue Feb 7, 2012 · 11 comments
Milestone

Comments

@remyoudompheng
Copy link
Contributor

What steps will reproduce the problem?
1. Create a test package

package test

const Value uint = 1
const Flag = 1 << Value

2. Run "go tool api test"

What is the expected output? What do you see instead?

Expected:
pkg test, const Value uint
pkg test, const Flag ideal-int

Got:
unknown kind in const "Flag" (*ast.BinaryExpr): in BinaryExpr, unhandled type
mismatch; left="ideal-int", right="uint"

If I try to add handling of unexported constants to cmd/api, I run into:

unknown kind in const "bias64" (*ast.BinaryExpr): in BinaryExpr, unhandled
type mismatch; left="uint", right="ideal-int"

when analyzing runtime/softfloat64.go
@bradfitz
Copy link
Contributor

bradfitz commented Feb 8, 2012

Comment 1:

I think I might've fixed this in the process of fixing 2906

Owner changed to @bradfitz.

Status changed to Started.

@bradfitz
Copy link
Contributor

bradfitz commented Feb 8, 2012

Comment 2:

Actually, why does this matter?
goapi isn't supposed to be a completely generic tool (at least not yet).  It's only
supposed to analyze the Go 1 codebase.
If it runs against the Go 1 codebase with correct results, that's good enough for now.
Once the AST has type information, then this tool gets less hacky.

Status changed to WaitingForReply.

@remyoudompheng
Copy link
Contributor Author

Comment 3:

It was a sub-isssue of 2906, I actually only found this on unexported constants so it's
a non-problem. I still have problems when running the tool on gccgo codebase (is it a
target for Go1?):
on os package:
unknown kind in const "WNOHANG" (*ast.SelectorExpr): unknown constant reference to
syscall.WNOHANG
on syscall package:
unknown type of variable "SizeofCmsghdr", type *ast.CallExpr, error = unresolved named
"int"
code: int(unsafe.Sizeof(Cmsghdr{}))
(here gccgo has var SizeofCmsgHdr instead of const SizeofMsgHdr, I guess that goes under
issue #1790).

@ianlancetaylor
Copy link
Contributor

Comment 4:

syscall.WNOHANG is defined in the generated file sysinfo.go.  Does goapi see that file
when you run it?  (I have not tried running goapi on the gccgo library.)
We could rewrite SizeofCmsgHdr and friends to be
    var SizeofCmsgHdr int = unsafe.Sizeof(Cmsghdr{})
but it would be even nicer if we could figure out a way to make them const as they are
for 6g.  I suppose we could change -fdump-go-spec to dump the size of every struct.

@bradfitz
Copy link
Contributor

bradfitz commented Feb 8, 2012

Comment 5:

Don't dirty up gccgo for my goapi's sake.  I'll make sure it works there.

@rsc
Copy link
Contributor

rsc commented Feb 14, 2012

Comment 6:

Labels changed: added priority-go1, go1-must, removed priority-triage.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Feb 28, 2012

Comment 7:

I tried to reproduce this and failed. Can you construct a complete example as part of
p1.go and p2.go (the testdata for the command)?

@remyoudompheng
Copy link
Contributor Author

Comment 8:

The original issue is supposed to have been fixed by
http://golang.org/cl/5644050, I believe.

@bradfitz
Copy link
Contributor

Comment 9:

Does cmd/api work with gccgo's tree?  We should repurpose this bug for that, or close
this and open an "audit gccgo vs. gc" bug.

@robpike
Copy link
Contributor

robpike commented Feb 29, 2012

Comment 10:

Opened https://golang.org/issue/3156
Closing this one.

@robpike
Copy link
Contributor

robpike commented Feb 29, 2012

Comment 11:

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@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

6 participants