From 8aa376beceb848bca08eb4233a2b40c5bff01508 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sun, 1 Oct 2023 03:38:05 +0800 Subject: [PATCH] aliasType __int128_t/__uint128_t --- cl/blockctx.go | 43 +++++++++++++++++++++++-------------------- cl/compile.go | 2 +- clang/ast/ast.go | 1 + 3 files changed, 25 insertions(+), 21 deletions(-) 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 d968e1e..013a009 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -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) } 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"