From 7f61989869052d9fd21502cba5d126ecc86ecce4 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 6 May 2024 08:21:47 +0800 Subject: [PATCH] fix warning --- chore/clangast/clangast.go | 8 +++++++- x/clang/types/parser/parser.go | 2 ++ x/clang/types/types.go | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/chore/clangast/clangast.go b/chore/clangast/clangast.go index 38c9e5f5..7d26a186 100644 --- a/chore/clangast/clangast.go +++ b/chore/clangast/clangast.go @@ -55,7 +55,7 @@ func main() { if e == nil { enc := json.NewEncoder(os.Stdout) enc.SetIndent("", " ") - enc.Encode(doc) + check(enc.Encode(doc)) return } err = e @@ -63,3 +63,9 @@ func main() { fmt.Fprintln(os.Stderr, err) os.Exit(1) } + +func check(err error) { + if err != nil { + panic(err) + } +} diff --git a/x/clang/types/parser/parser.go b/x/clang/types/parser/parser.go index 6a270517..56250cac 100644 --- a/x/clang/types/parser/parser.go +++ b/x/clang/types/parser/parser.go @@ -189,6 +189,7 @@ func (p *parser) newError(errMsg string) *ParseTypeError { return &ParseTypeError{QualType: p.s.Source(), ErrMsg: errMsg} } +// TODO(xsw): check expect results func (p *parser) expect(tokExp token.Token) error { p.next() if p.tok != tokExp { @@ -330,6 +331,7 @@ func (p *parser) parseFunc(pkg *types.Package, t types.Type, inFlags int) (ret t if err != nil { return } + _ = inFlags return ctypes.NewFunc(types.NewTuple(args...), results, variadic), nil } diff --git a/x/clang/types/types.go b/x/clang/types/types.go index 272541ef..df52fa95 100644 --- a/x/clang/types/types.go +++ b/x/clang/types/types.go @@ -74,7 +74,7 @@ func NewPointer(typ types.Type) types.Type { } case *types.Signature: if gogen.IsCSignature(t) { - return types.NewSignature(nil, t.Params(), t.Results(), t.Variadic()) + return types.NewSignatureType(nil, nil, nil, t.Params(), t.Results(), t.Variadic()) } case *types.Named: if typ == ValistTag {