diff --git a/cl/blockctx.go b/cl/blockctx.go index 9319b51..2b3fc0e 100644 --- a/cl/blockctx.go +++ b/cl/blockctx.go @@ -502,27 +502,27 @@ func (p *bfType) String() string { } /* -func (p *blockCtx) initCTypes() { - pkg := p.pkg.Types - scope := pkg.Scope() - p.tyI128 = ctypes.NotImpl - p.tyU128 = ctypes.NotImpl - c := p.pkg.Import("github.com/goplus/c2go/clang") - - aliasType(scope, pkg, "__int128", p.tyI128) - aliasType(scope, pkg, "void", ctypes.Void) - - aliasCType(scope, pkg, "char", c, "Char") - aliasCType(scope, pkg, "float", c, "Float") - aliasCType(scope, pkg, "double", c, "Double") - aliasCType(scope, pkg, "_Bool", c, "Bool") - - decl_builtin(p) -} + func (p *blockCtx) initCTypes() { + pkg := p.pkg.Types + scope := pkg.Scope() + p.tyI128 = ctypes.NotImpl + p.tyU128 = ctypes.NotImpl + c := p.pkg.Import("github.com/goplus/c2go/clang") + + aliasType(scope, pkg, "__int128", p.tyI128) + aliasType(scope, pkg, "void", ctypes.Void) + + aliasCType(scope, pkg, "char", c, "Char") + aliasCType(scope, pkg, "float", c, "Float") + aliasCType(scope, pkg, "double", c, "Double") + aliasCType(scope, pkg, "_Bool", c, "Bool") + + decl_builtin(p) + } -func aliasCType(scope *types.Scope, pkg *types.Package, name string, c *gox.PkgRef, cname string) { - aliasType(scope, pkg, name, c.Ref(cname).Type()) -} + func aliasCType(scope *types.Scope, pkg *types.Package, name string, c *gox.PkgRef, cname string) { + aliasType(scope, pkg, name, c.Ref(cname).Type()) + } */ func (p *blockCtx) initCTypes() { pkg := p.pkg.Types @@ -531,6 +531,9 @@ func (p *blockCtx) initCTypes() { p.tyU128 = ctypes.NotImpl aliasType(scope, pkg, "__int128", p.tyI128) + aliasType(scope, pkg, "__int128_t", p.tyI128) + aliasType(scope, pkg, "__uint128_t", p.tyU128) + aliasType(scope, pkg, "void", ctypes.Void) aliasType(scope, pkg, "char", types.Typ[types.Int8]) diff --git a/cl/compile.go b/cl/compile.go index 63ad1e4..be9c09c 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -217,7 +217,7 @@ func NewPackage(pkgPath, pkgName string, file *ast.Node, conf *Config) (pkg Pack pkg.Package = gox.NewPackage(pkgPath, pkgName, confGox) interp.fset = pkg.Fset } - pkg.SetVarRedeclarable(true) + pkg.SetRedeclarable(true) pkg.pi, err = loadFile(pkg.Package, conf, file) return } @@ -402,7 +402,7 @@ func compileFunc(ctx *blockCtx, fn *ast.Node) { ast.AlwaysInlineAttr, ast.WarnUnusedResultAttr, ast.NoThrowAttr, ast.NoInlineAttr, ast.AllocSizeAttr, ast.NonNullAttr, ast.ConstAttr, ast.PureAttr, ast.GNUInlineAttr, ast.ReturnsTwiceAttr, ast.NoSanitizeAttr, ast.RestrictAttr, ast.MSAllocatorAttr, ast.VisibilityAttr, ast.C11NoReturnAttr, ast.StrictFPAttr, - ast.AllocAlignAttr, ast.DisableTailCallsAttr: + ast.AllocAlignAttr, ast.DisableTailCallsAttr, ast.FormatArgAttr: default: log.Panicln("compileFunc: unknown kind =", item.Kind) } @@ -436,7 +436,7 @@ func compileFunc(ctx *blockCtx, fn *ast.Node) { } if rewritten { // for fnName is a recursive function scope := pkg.Types.Scope() - substObj(pkg.Types, scope, origName, f.Func) + substObj(pkg.Types, scope, origName, f.Obj()) rewritten = false } cb := f.BodyStart(pkg) @@ -468,7 +468,7 @@ func compileFunc(ctx *blockCtx, fn *ast.Node) { cb.Val(pkg.Import("os").Ref("Exit")).Typ(types.Typ[types.Int]) } } - cb.Val(f.Func) + cb.Val(f.Obj()) if params != nil { panic("TODO: main func with params") } diff --git a/cl/multifiles.go b/cl/multifiles.go index 04ba779..b6c6b7c 100644 --- a/cl/multifiles.go +++ b/cl/multifiles.go @@ -145,7 +145,6 @@ func (p *blockCtx) logFile(node *ast.Node) { } } } - return } func (p *blockCtx) checkExists(name string) (exist bool) { diff --git a/cl/stmtchk.go b/cl/stmtchk.go index 52934d2..6b42e10 100644 --- a/cl/stmtchk.go +++ b/cl/stmtchk.go @@ -42,12 +42,14 @@ func (at *blockMarkCtx) markComplicated(ctx *markCtx, ref *blockMarkCtx) { } } +/* func (at *blockMarkCtx) getName() string { if at != nil { return at.name } return "funcBody" } +*/ func (at *blockMarkCtx) depth() (n int) { for at != nil { @@ -265,7 +267,6 @@ func (p *markCtx) markSwitch(ctx *blockCtx, switchStmt *ast.Node) { p.mark(ctx, caseBody) } } - return } func (p *markCtx) markEnd() { diff --git a/cl/type_and_var.go b/cl/type_and_var.go index bf6a009..04204a0 100644 --- a/cl/type_and_var.go +++ b/cl/type_and_var.go @@ -597,9 +597,11 @@ func isNumber(typ types.Type) bool { return isKind(typ, types.IsInteger|types.IsFloat) } +/* func isUnsigned(typ types.Type) bool { return isKind(typ, types.IsUnsigned) } +*/ func isInteger(typ types.Type) bool { return isKind(typ, types.IsInteger) diff --git a/clang/ast/ast.go b/clang/ast/ast.go index b67b839..1306047 100644 --- a/clang/ast/ast.go +++ b/clang/ast/ast.go @@ -60,6 +60,7 @@ const ( DeprecatedAttr Kind = "DeprecatedAttr" BuiltinAttr Kind = "BuiltinAttr" FormatAttr Kind = "FormatAttr" + FormatArgAttr Kind = "FormatArgAttr" ColdAttr Kind = "ColdAttr" ConstAttr Kind = "ConstAttr" PureAttr Kind = "PureAttr" diff --git a/go.mod b/go.mod index a20a3a5..ac48bf6 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/goplus/c2go go 1.16 require ( - github.com/goplus/gox v1.11.38 + github.com/goplus/gox v1.12.0 github.com/goplus/mod v0.11.5 github.com/json-iterator/go v1.1.12 github.com/qiniu/x v1.13.0 diff --git a/go.sum b/go.sum index 7022dab..6318c61 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/goplus/gox v1.11.38 h1:znqKvaIOx/zpVBPpF5NNFO+DuQ/8UpvO0hIqFb45SlY= -github.com/goplus/gox v1.11.38/go.mod h1:QQfPGKVmtAzat6fDYE4V4PFo/v95zvrwB9M60tbqdMM= +github.com/goplus/gox v1.12.0 h1:VkQrIhVaKTYARQUUN+Q0+k8DtOXQqOvC6zaZP8wyG5E= +github.com/goplus/gox v1.12.0/go.mod h1:Ek4bXv4xzfBiFuHC6yfkzHXrhUHXfrM9QyXtMusdkGo= github.com/goplus/mod v0.11.5 h1:3zcWlkLq/adU+y8GynZRMjSE50DfbnILdkRnToDaq24= github.com/goplus/mod v0.11.5/go.mod h1:NDC5E+XOT8vcJCMjqKhLDJHTHX7lyVN4Vbfi2U7dBhs= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=