diff options
Diffstat (limited to 'vendor/modernc.org/cc/v3')
-rw-r--r-- | vendor/modernc.org/cc/v3/CONTRIBUTORS | 1 | ||||
-rw-r--r-- | vendor/modernc.org/cc/v3/Makefile | 7 | ||||
-rw-r--r-- | vendor/modernc.org/cc/v3/abi.go | 8 | ||||
-rw-r--r-- | vendor/modernc.org/cc/v3/abi_platforms.go | 199 | ||||
-rw-r--r-- | vendor/modernc.org/cc/v3/cc.go | 1 | ||||
-rw-r--r-- | vendor/modernc.org/cc/v3/check.go | 8 | ||||
-rw-r--r-- | vendor/modernc.org/cc/v3/parser.go | 73 |
7 files changed, 266 insertions, 31 deletions
diff --git a/vendor/modernc.org/cc/v3/CONTRIBUTORS b/vendor/modernc.org/cc/v3/CONTRIBUTORS index 69eb75cc..19316e88 100644 --- a/vendor/modernc.org/cc/v3/CONTRIBUTORS +++ b/vendor/modernc.org/cc/v3/CONTRIBUTORS @@ -16,3 +16,4 @@ Steffen Butzer <steffen(dot)butzer@outlook.com> Tommi Virtanen <tv@eagain.net> Yasuhiro Matsumoto <mattn.jp@gmail.com> Zvi Effron <zeffron@cs.hmc.edu> +Lucas Raab <tuftedocelot@fastmail.fm> diff --git a/vendor/modernc.org/cc/v3/Makefile b/vendor/modernc.org/cc/v3/Makefile index 68e39907..3664010d 100644 --- a/vendor/modernc.org/cc/v3/Makefile +++ b/vendor/modernc.org/cc/v3/Makefile @@ -63,14 +63,21 @@ build_all_targets: GOOS=darwin GOARCH=arm64 go build -v ./... GOOS=freebsd GOARCH=386 go build -v ./... GOOS=freebsd GOARCH=amd64 go build -v ./... + GOOS=freebsd GOARCH=arm go build -v ./... + GOOS=freebsd GOARCH=arm64 go build -v ./... GOOS=linux GOARCH=386 go build -v ./... GOOS=linux GOARCH=amd64 go build -v ./... GOOS=linux GOARCH=arm go build -v ./... GOOS=linux GOARCH=arm64 go build -v ./... + GOOS=linux GOARCH=ppc64le go build -v ./... GOOS=linux GOARCH=riscv64 go build -v ./... GOOS=linux GOARCH=s390x go build -v ./... GOOS=netbsd GOARCH=amd64 go build -v ./... + GOOS=netbsd GOARCH=arm go build -v ./... + GOOS=netbsd GOARCH=386 go build -v ./... GOOS=openbsd GOARCH=amd64 go build -v ./... + GOOS=openbsd GOARCH=arm64 go build -v ./... + GOOS=openbsd GOARCH=386 go build -v ./... GOOS=windows GOARCH=386 go build -v ./... GOOS=windows GOARCH=amd64 go build -v ./... GOOS=windows GOARCH=arm64 go build -v ./... diff --git a/vendor/modernc.org/cc/v3/abi.go b/vendor/modernc.org/cc/v3/abi.go index e0325584..bf46d6cf 100644 --- a/vendor/modernc.org/cc/v3/abi.go +++ b/vendor/modernc.org/cc/v3/abi.go @@ -395,8 +395,12 @@ func (a *ABI) layout(ctx *context, n Node, t *structType) *structType { group += f.bitFieldWidth default: if n := group % 64; n != 0 { - group -= n - off += int64(normalizeBitFieldWidth(group) - group) + if ctx.cfg.FixBitfieldPadding { + off += int64(normalizeBitFieldWidth(group-n) - group) + } else { + group -= n + off += int64(normalizeBitFieldWidth(group) - group) + } } off0 := off off = roundup(off, 8*int64(al)) diff --git a/vendor/modernc.org/cc/v3/abi_platforms.go b/vendor/modernc.org/cc/v3/abi_platforms.go index fdd56520..99850172 100644 --- a/vendor/modernc.org/cc/v3/abi_platforms.go +++ b/vendor/modernc.org/cc/v3/abi_platforms.go @@ -15,20 +15,26 @@ var ( } abiSignedChar = map[[2]string]bool{ + {"freebsd", "arm"}: false, + {"freebsd", "arm64"}: false, {"linux", "arm"}: false, {"linux", "arm64"}: false, - {"linux", "s390x"}: false, {"linux", "ppc64le"}: false, {"linux", "riscv64"}: false, + {"linux", "s390x"}: false, + {"netbsd", "arm"}: false, {"darwin", "amd64"}: true, {"darwin", "arm64"}: true, - {"freebsd", "amd64"}: true, {"freebsd", "386"}: true, + {"freebsd", "amd64"}: true, {"linux", "386"}: true, {"linux", "amd64"}: true, + {"netbsd", "386"}: true, {"netbsd", "amd64"}: true, + {"openbsd", "386"}: true, {"openbsd", "amd64"}: true, + {"openbsd", "arm64"}: true, {"windows", "386"}: true, {"windows", "amd64"}: true, {"windows", "arm64"}: true, @@ -411,6 +417,38 @@ var abiTypes = map[[2]string]map[Kind]ABIType{ Int128: {16, 16, 16}, UInt128: {16, 16, 16}, }, + // gcc (FreeBSD Ports Collection) 11.3.0 + {"freebsd", "arm64"}: { + Void: {1, 1, 1}, + Bool: {1, 1, 1}, + Char: {1, 1, 1}, + SChar: {1, 1, 1}, + UChar: {1, 1, 1}, + Short: {2, 2, 2}, + UShort: {2, 2, 2}, + Enum: {4, 4, 4}, + Int: {4, 4, 4}, + UInt: {4, 4, 4}, + Long: {8, 8, 8}, + ULong: {8, 8, 8}, + LongLong: {8, 8, 8}, + ULongLong: {8, 8, 8}, + Ptr: {8, 8, 8}, + Function: {8, 8, 8}, + Float: {4, 4, 4}, + Double: {8, 8, 8}, + LongDouble: {16, 16, 16}, + Int8: {1, 1, 1}, + UInt8: {1, 1, 1}, + Int16: {2, 2, 2}, + UInt16: {2, 2, 2}, + Int32: {4, 4, 4}, + UInt32: {4, 4, 4}, + Int64: {8, 8, 8}, + UInt64: {8, 8, 8}, + Int128: {16, 16, 16}, + UInt128: {16, 16, 16}, + }, // gcc (FreeBSD Ports Collection) 10.3.0 {"freebsd", "386"}: { Void: {1, 1, 1}, @@ -446,6 +484,36 @@ var abiTypes = map[[2]string]map[Kind]ABIType{ Float64x: {16, 16, 16}, Float128: {16, 16, 16}, }, + // gcc (FreeBSD Ports Collection) 11.3.0 + {"freebsd", "arm"}: { + Void: {1, 1, 1}, + Bool: {1, 1, 1}, + Char: {1, 1, 1}, + SChar: {1, 1, 1}, + UChar: {1, 1, 1}, + Short: {2, 2, 2}, + UShort: {2, 2, 2}, + Enum: {4, 4, 4}, + Int: {4, 4, 4}, + UInt: {4, 4, 4}, + Long: {4, 4, 4}, + ULong: {4, 4, 4}, + LongLong: {8, 8, 8}, + ULongLong: {8, 8, 8}, + Ptr: {4, 4, 4}, + Function: {4, 4, 4}, + Float: {4, 4, 4}, + Double: {8, 8, 8}, + LongDouble: {8, 8, 8}, + Int8: {1, 1, 1}, + UInt8: {1, 1, 1}, + Int16: {2, 2, 2}, + UInt16: {2, 2, 2}, + Int32: {4, 4, 4}, + UInt32: {4, 4, 4}, + Int64: {8, 8, 8}, + UInt64: {8, 8, 8}, + }, // gcc (GCC) 8.4.0 {"openbsd", "amd64"}: { Void: {1, 1, 1}, @@ -483,6 +551,68 @@ var abiTypes = map[[2]string]map[Kind]ABIType{ Float64x: {16, 16, 16}, Float128: {16, 16, 16}, }, + // OpenBSD clang version 13.0.0 + {"openbsd", "arm64"}: { + Void: {1, 1, 1}, + Bool: {1, 1, 1}, + Char: {1, 1, 1}, + SChar: {1, 1, 1}, + UChar: {1, 1, 1}, + Short: {2, 2, 2}, + UShort: {2, 2, 2}, + Enum: {4, 4, 4}, + Int: {4, 4, 4}, + UInt: {4, 4, 4}, + Long: {8, 8, 8}, + ULong: {8, 8, 8}, + LongLong: {8, 8, 8}, + ULongLong: {8, 8, 8}, + Ptr: {8, 8, 8}, + Function: {8, 8, 8}, + Float: {4, 4, 4}, + Double: {8, 8, 8}, + LongDouble: {16, 16, 16}, + Int8: {1, 1, 1}, + UInt8: {1, 1, 1}, + Int16: {2, 2, 2}, + UInt16: {2, 2, 2}, + Int32: {4, 4, 4}, + UInt32: {4, 4, 4}, + Int64: {8, 8, 8}, + UInt64: {8, 8, 8}, + Int128: {16, 16, 16}, + UInt128: {16, 16, 16}, + }, + // OpenBSD clang version 13.0.0 + {"openbsd", "386"}: { + Void: {1, 1, 1}, + Bool: {1, 1, 1}, + Char: {1, 1, 1}, + SChar: {1, 1, 1}, + UChar: {1, 1, 1}, + Short: {2, 2, 2}, + UShort: {2, 2, 2}, + Enum: {4, 4, 4}, + Int: {4, 4, 4}, + UInt: {4, 4, 4}, + Long: {4, 4, 4}, + ULong: {4, 4, 4}, + LongLong: {8, 4, 4}, + ULongLong: {8, 4, 4}, + Ptr: {4, 4, 4}, + Function: {4, 4, 4}, + Float: {4, 4, 4}, + Double: {8, 4, 4}, + LongDouble: {12, 4, 4}, + Int8: {1, 1, 1}, + UInt8: {1, 1, 1}, + Int16: {2, 2, 2}, + UInt16: {2, 2, 2}, + Int32: {4, 4, 4}, + UInt32: {4, 4, 4}, + Int64: {8, 4, 4}, + UInt64: {8, 4, 4}, + }, // gcc (GCC) 10.3.0 {"netbsd", "amd64"}: { Void: {1, 1, 1}, @@ -515,6 +645,71 @@ var abiTypes = map[[2]string]map[Kind]ABIType{ Int128: {16, 16, 16}, UInt128: {16, 16, 16}, }, + // gcc (nb4 20200810) 7.5.0 + {"netbsd", "arm"}: { + Void: {1, 1, 1}, + Bool: {1, 1, 1}, + Char: {1, 1, 1}, + SChar: {1, 1, 1}, + UChar: {1, 1, 1}, + Short: {2, 2, 2}, + UShort: {2, 2, 2}, + Enum: {4, 4, 4}, + Int: {4, 4, 4}, + UInt: {4, 4, 4}, + Long: {4, 4, 4}, + ULong: {4, 4, 4}, + LongLong: {8, 8, 8}, + ULongLong: {8, 8, 8}, + Ptr: {4, 4, 4}, + Function: {4, 4, 4}, + Float: {4, 4, 4}, + Double: {8, 8, 8}, + LongDouble: {8, 8, 8}, + Int8: {1, 1, 1}, + UInt8: {1, 1, 1}, + Int16: {2, 2, 2}, + UInt16: {2, 2, 2}, + Int32: {4, 4, 4}, + UInt32: {4, 4, 4}, + Int64: {8, 8, 8}, + UInt64: {8, 8, 8}, + }, + // gcc (nb4 20200810) 7.5.0 + {"netbsd", "386"}: { + Void: {1, 1, 1}, + Bool: {1, 1, 1}, + Char: {1, 1, 1}, + SChar: {1, 1, 1}, + UChar: {1, 1, 1}, + Short: {2, 2, 2}, + UShort: {2, 2, 2}, + Enum: {4, 4, 4}, + Int: {4, 4, 4}, + UInt: {4, 4, 4}, + Long: {4, 4, 4}, + ULong: {4, 4, 4}, + LongLong: {8, 4, 4}, + ULongLong: {8, 4, 4}, + Ptr: {4, 4, 4}, + Function: {4, 4, 4}, + Float: {4, 4, 4}, + Double: {8, 4, 4}, + LongDouble: {12, 4, 4}, + Int8: {1, 1, 1}, + UInt8: {1, 1, 1}, + Int16: {2, 2, 2}, + UInt16: {2, 2, 2}, + Int32: {4, 4, 4}, + UInt32: {4, 4, 4}, + Int64: {8, 4, 4}, + UInt64: {8, 4, 4}, + Float32: {4, 4, 4}, + Float32x: {8, 4, 4}, + Float64: {8, 4, 4}, + Float64x: {12, 4, 4}, + Float128: {16, 16, 16}, + }, // gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0 {"linux", "riscv64"}: { Void: {1, 1, 1}, diff --git a/vendor/modernc.org/cc/v3/cc.go b/vendor/modernc.org/cc/v3/cc.go index dc8f98a3..248a9b01 100644 --- a/vendor/modernc.org/cc/v3/cc.go +++ b/vendor/modernc.org/cc/v3/cc.go @@ -528,6 +528,7 @@ type Config struct { DebugWorkingDir bool // Output to stderr. DoNotTypecheckAsm bool EnableAssignmentCompatibilityChecking bool // No such checks performed up to v3.31.0. Currently only partially implemented. + FixBitfieldPadding bool // Fix a bug in calculating field positions after a bitfield. InjectTracingCode bool // Output to stderr. LongDoubleIsDouble bool PreprocessOnly bool diff --git a/vendor/modernc.org/cc/v3/check.go b/vendor/modernc.org/cc/v3/check.go index 50887870..a523760f 100644 --- a/vendor/modernc.org/cc/v3/check.go +++ b/vendor/modernc.org/cc/v3/check.go @@ -1138,6 +1138,10 @@ func (n *UnaryExpression) check(ctx *context, isAsmArg bool) Operand { case UnaryExpressionPlus: // '+' CastExpression op := n.CastExpression.check(ctx, isAsmArg) n.IsSideEffectsFree = n.CastExpression.IsSideEffectsFree + if op == nil { + //TODO report error + break + } if !op.Type().IsArithmeticType() { //TODO report error break @@ -1150,6 +1154,10 @@ func (n *UnaryExpression) check(ctx *context, isAsmArg bool) Operand { case UnaryExpressionMinus: // '-' CastExpression op := n.CastExpression.check(ctx, isAsmArg) n.IsSideEffectsFree = n.CastExpression.IsSideEffectsFree + if op == nil { + //TODO report error + break + } if op.Type().Kind() == Vector { n.Operand = &operand{abi: &ctx.cfg.ABI, typ: op.Type()} break diff --git a/vendor/modernc.org/cc/v3/parser.go b/vendor/modernc.org/cc/v3/parser.go index d73b2c6b..a2b5f3c7 100644 --- a/vendor/modernc.org/cc/v3/parser.go +++ b/vendor/modernc.org/cc/v3/parser.go @@ -3162,28 +3162,49 @@ func (p *parser) designator(acceptCol bool) (*Designator, bool) { // iteration-statement // jump-statement // asm-statement -func (p *parser) statement() *Statement { - switch p.rune() { - case IDENTIFIER: - if p.peek(false) == ':' { - return &Statement{Case: StatementLabeled, LabeledStatement: p.labeledStatement()} +func (p *parser) statement() (r *Statement) { + var r0 *Statement + var prevLS, ls *LabeledStatement + + defer func() { + if ls != nil { + ls.Statement = r + r = r0 } + }() - return &Statement{Case: StatementExpr, ExpressionStatement: p.expressionStatement()} - case '{': - return &Statement{Case: StatementCompound, CompoundStatement: p.compoundStatement(nil, nil)} - case IF, SWITCH: - return &Statement{Case: StatementSelection, SelectionStatement: p.selectionStatement()} - case WHILE, DO, FOR: - return &Statement{Case: StatementIteration, IterationStatement: p.iterationStatement()} - case GOTO, BREAK, CONTINUE, RETURN: - return &Statement{Case: StatementJump, JumpStatement: p.jumpStatement()} - case CASE, DEFAULT: - return &Statement{Case: StatementLabeled, LabeledStatement: p.labeledStatement()} - case ASM: - return &Statement{Case: StatementAsm, AsmStatement: p.asmStatement()} - default: - return &Statement{Case: StatementExpr, ExpressionStatement: p.expressionStatement()} + for { + switch p.rune() { + case IDENTIFIER: + switch { + case p.peek(false) == ':': + ls = p.labeledStatement() + default: + return &Statement{Case: StatementExpr, ExpressionStatement: p.expressionStatement()} + } + case '{': + return &Statement{Case: StatementCompound, CompoundStatement: p.compoundStatement(nil, nil)} + case IF, SWITCH: + return &Statement{Case: StatementSelection, SelectionStatement: p.selectionStatement()} + case WHILE, DO, FOR: + return &Statement{Case: StatementIteration, IterationStatement: p.iterationStatement()} + case GOTO, BREAK, CONTINUE, RETURN: + return &Statement{Case: StatementJump, JumpStatement: p.jumpStatement()} + case CASE, DEFAULT: + ls = p.labeledStatement() + case ASM: + return &Statement{Case: StatementAsm, AsmStatement: p.asmStatement()} + default: + return &Statement{Case: StatementExpr, ExpressionStatement: p.expressionStatement()} + } + + switch { + case r0 == nil: + r0 = &Statement{Case: StatementLabeled, LabeledStatement: ls} + default: + prevLS.Statement = &Statement{Case: StatementLabeled, LabeledStatement: ls} + } + prevLS = ls } } @@ -3220,7 +3241,7 @@ func (p *parser) labeledStatement() (r *LabeledStatement) { p.block.hasLabel() r = &LabeledStatement{ Case: LabeledStatementLabel, Token: t, Token2: t2, AttributeSpecifierList: attr, - Statement: p.statement(), lexicalScope: p.declScope, block: p.block, + lexicalScope: p.declScope, block: p.block, } p.declScope.declare(t.Value, r) return r @@ -3246,8 +3267,7 @@ func (p *parser) labeledStatement() (r *LabeledStatement) { return &LabeledStatement{ Case: LabeledStatementRange, Token: t, ConstantExpression: e, Token2: t2, ConstantExpression2: e2, Token3: t3, - Statement: p.statement(), lexicalScope: p.declScope, - block: p.block, + lexicalScope: p.declScope, block: p.block, } case ':': t2 = p.shift() @@ -3256,8 +3276,7 @@ func (p *parser) labeledStatement() (r *LabeledStatement) { } return &LabeledStatement{ Case: LabeledStatementCaseLabel, Token: t, ConstantExpression: e, - Token2: t2, Statement: p.statement(), lexicalScope: p.declScope, - block: p.block, + Token2: t2, lexicalScope: p.declScope, block: p.block, } case DEFAULT: if p.switches == 0 { @@ -3271,12 +3290,12 @@ func (p *parser) labeledStatement() (r *LabeledStatement) { p.err("expected :") } return &LabeledStatement{ - Case: LabeledStatementDefault, Token: t, Token2: t2, Statement: p.statement(), + Case: LabeledStatementDefault, Token: t, Token2: t2, lexicalScope: p.declScope, block: p.block, } default: p.err("expected labeled-statement") - return nil + return &LabeledStatement{} } } |