authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-12-19 20:54:39+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-12-19 20:58:48+02:00
log61482be15380be22c8333ff4c6557108596efba2
treee82c17a5d615cf50ceb0c572ef55eda1d7ba876b
parentf837c7c9cd8f355aeea1dea1e9b328820802ee34
signature Commit is signed but in an unrecognized format.

translate-c-2 improve macro fn ptr caller


4 files changed, 131 insertions(+), 92 deletions(-)

lib/std/zig/ast.zig+4-4
......@@ -1436,8 +1436,8 @@ pub const Node = struct {
14361436 AssignMod,
14371437 AssignAdd,
14381438 AssignAddWrap,
1439 AssignMult,
1440 AssignMultWrap,
1439 AssignMul,
1440 AssignMulWrap,
14411441 BangEqual,
14421442 BitAnd,
14431443 BitOr,
......@@ -1495,8 +1495,8 @@ pub const Node = struct {
14951495 Op.AssignMod,
14961496 Op.AssignAdd,
14971497 Op.AssignAddWrap,
1498 Op.AssignMult,
1499 Op.AssignMultWrap,
1498 Op.AssignMul,
1499 Op.AssignMulWrap,
15001500 Op.BangEqual,
15011501 Op.BitAnd,
15021502 Op.BitOr,
lib/std/zig/parse.zig+2-2
......@@ -1981,7 +1981,7 @@ fn parseAssignOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
19811981
19821982 const token = nextToken(it);
19831983 const op = switch (token.ptr.id) {
1984 .AsteriskEqual => Op{ .AssignMult = {} },
1984 .AsteriskEqual => Op{ .AssignMul = {} },
19851985 .SlashEqual => Op{ .AssignDiv = {} },
19861986 .PercentEqual => Op{ .AssignMod = {} },
19871987 .PlusEqual => Op{ .AssignAdd = {} },
......@@ -1991,7 +1991,7 @@ fn parseAssignOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
19911991 .AmpersandEqual => Op{ .AssignBitAnd = {} },
19921992 .CaretEqual => Op{ .AssignBitXor = {} },
19931993 .PipeEqual => Op{ .AssignBitOr = {} },
1994 .AsteriskPercentEqual => Op{ .AssignMultWrap = {} },
1994 .AsteriskPercentEqual => Op{ .AssignMulWrap = {} },
19951995 .PlusPercentEqual => Op{ .AssignAddWrap = {} },
19961996 .MinusPercentEqual => Op{ .AssignSubWrap = {} },
19971997 .Equal => Op{ .Assign = {} },
src-self-hosted/translate_c.zig+117-78
......@@ -8,6 +8,7 @@ const Token = std.zig.Token;
88usingnamespace @import("clang.zig");
99const ctok = @import("c_tokenizer.zig");
1010const CToken = ctok.CToken;
11const mem = std.mem;
1112
1213const CallingConvention = std.builtin.TypeInfo.CallingConvention;
1314
......@@ -83,7 +84,7 @@ const Scope = struct {
8384 fn getAlias(scope: *Block, name: []const u8) ?[]const u8 {
8485 var it = scope.variables.iterator(0);
8586 while (it.next()) |p| {
86 if (std.mem.eql(u8, p.name, name))
87 if (mem.eql(u8, p.name, name))
8788 return p.alias;
8889 }
8990 return scope.base.parent.?.getAlias(name);
......@@ -92,7 +93,7 @@ const Scope = struct {
9293 fn contains(scope: *Block, name: []const u8) bool {
9394 var it = scope.variables.iterator(0);
9495 while (it.next()) |p| {
95 if (std.mem.eql(u8, p.name, name))
96 if (mem.eql(u8, p.name, name))
9697 return true;
9798 }
9899 return scope.base.parent.?.contains(name);
......@@ -137,7 +138,7 @@ const Scope = struct {
137138 fn getAlias(scope: *FnDef, name: []const u8) ?[]const u8 {
138139 var it = scope.params.iterator(0);
139140 while (it.next()) |p| {
140 if (std.mem.eql(u8, p.name, name))
141 if (mem.eql(u8, p.name, name))
141142 return p.alias;
142143 }
143144 return scope.base.parent.?.getAlias(name);
......@@ -146,7 +147,7 @@ const Scope = struct {
146147 fn contains(scope: *FnDef, name: []const u8) bool {
147148 var it = scope.params.iterator(0);
148149 while (it.next()) |p| {
149 if (std.mem.eql(u8, p.name, name))
150 if (mem.eql(u8, p.name, name))
150151 return true;
151152 }
152153 return scope.base.parent.?.contains(name);
......@@ -233,13 +234,13 @@ const Context = struct {
233234 return c.mangle_count;
234235 }
235236
236 fn a(c: *Context) *std.mem.Allocator {
237 fn a(c: *Context) *mem.Allocator {
237238 return &c.tree.arena_allocator.allocator;
238239 }
239240
240241 /// Convert a null-terminated C string to a slice allocated in the arena
241242 fn str(c: *Context, s: [*:0]const u8) ![]u8 {
242 return std.mem.dupe(c.a(), u8, std.mem.toSliceConst(u8, s));
243 return mem.dupe(c.a(), u8, mem.toSliceConst(u8, s));
243244 }
244245
245246 /// Convert a clang source location to a file:line:column string
......@@ -255,7 +256,7 @@ const Context = struct {
255256};
256257
257258pub fn translate(
258 backing_allocator: *std.mem.Allocator,
259 backing_allocator: *mem.Allocator,
259260 args_begin: [*]?[*]const u8,
260261 args_end: [*]?[*]const u8,
261262 errors: *[]ClangErrMsg,
......@@ -540,29 +541,29 @@ fn transTypeDef(c: *Context, typedef_decl: *const ZigClangTypedefNameDecl) Error
540541
541542 const typedef_name = try c.str(ZigClangDecl_getName_bytes_begin(@ptrCast(*const ZigClangDecl, typedef_decl)));
542543
543 if (std.mem.eql(u8, typedef_name, "uint8_t"))
544 if (mem.eql(u8, typedef_name, "uint8_t"))
544545 return transTypeDefAsBuiltin(c, typedef_decl, "u8")
545 else if (std.mem.eql(u8, typedef_name, "int8_t"))
546 else if (mem.eql(u8, typedef_name, "int8_t"))
546547 return transTypeDefAsBuiltin(c, typedef_decl, "i8")
547 else if (std.mem.eql(u8, typedef_name, "uint16_t"))
548 else if (mem.eql(u8, typedef_name, "uint16_t"))
548549 return transTypeDefAsBuiltin(c, typedef_decl, "u16")
549 else if (std.mem.eql(u8, typedef_name, "int16_t"))
550 else if (mem.eql(u8, typedef_name, "int16_t"))
550551 return transTypeDefAsBuiltin(c, typedef_decl, "i16")
551 else if (std.mem.eql(u8, typedef_name, "uint32_t"))
552 else if (mem.eql(u8, typedef_name, "uint32_t"))
552553 return transTypeDefAsBuiltin(c, typedef_decl, "u32")
553 else if (std.mem.eql(u8, typedef_name, "int32_t"))
554 else if (mem.eql(u8, typedef_name, "int32_t"))
554555 return transTypeDefAsBuiltin(c, typedef_decl, "i32")
555 else if (std.mem.eql(u8, typedef_name, "uint64_t"))
556 else if (mem.eql(u8, typedef_name, "uint64_t"))
556557 return transTypeDefAsBuiltin(c, typedef_decl, "u64")
557 else if (std.mem.eql(u8, typedef_name, "int64_t"))
558 else if (mem.eql(u8, typedef_name, "int64_t"))
558559 return transTypeDefAsBuiltin(c, typedef_decl, "i64")
559 else if (std.mem.eql(u8, typedef_name, "intptr_t"))
560 else if (mem.eql(u8, typedef_name, "intptr_t"))
560561 return transTypeDefAsBuiltin(c, typedef_decl, "isize")
561 else if (std.mem.eql(u8, typedef_name, "uintptr_t"))
562 else if (mem.eql(u8, typedef_name, "uintptr_t"))
562563 return transTypeDefAsBuiltin(c, typedef_decl, "usize")
563 else if (std.mem.eql(u8, typedef_name, "ssize_t"))
564 else if (mem.eql(u8, typedef_name, "ssize_t"))
564565 return transTypeDefAsBuiltin(c, typedef_decl, "isize")
565 else if (std.mem.eql(u8, typedef_name, "size_t"))
566 else if (mem.eql(u8, typedef_name, "size_t"))
566567 return transTypeDefAsBuiltin(c, typedef_decl, "usize");
567568
568569 _ = try c.decl_table.put(@ptrToInt(ZigClangTypedefNameDecl_getCanonicalDecl(typedef_decl)), typedef_name);
......@@ -704,7 +705,7 @@ fn transEnumDecl(c: *Context, enum_decl: *const ZigClangEnumDecl) Error!?*ast.No
704705
705706 const name = try std.fmt.allocPrint(c.a(), "enum_{}", .{bare_name});
706707 _ = try c.decl_table.put(@ptrToInt(ZigClangEnumDecl_getCanonicalDecl(enum_decl)), name);
707 const node = try transCreateNodeVarDecl(c, true, true, name);
708 const node = try transCreateNodeVarDecl(c, !is_unnamed, true, name);
708709 node.eq_token = try appendToken(c, .Equal, "=");
709710
710711 node.init_node = if (ZigClangEnumDecl_getDefinition(enum_decl)) |enum_def| blk: {
......@@ -762,7 +763,7 @@ fn transEnumDecl(c: *Context, enum_decl: *const ZigClangEnumDecl) Error!?*ast.No
762763
763764 const enum_val_name = try c.str(ZigClangDecl_getName_bytes_begin(@ptrCast(*const ZigClangDecl, enum_const)));
764765
765 const field_name = if (!is_unnamed and std.mem.startsWith(u8, enum_val_name, bare_name))
766 const field_name = if (!is_unnamed and mem.startsWith(u8, enum_val_name, bare_name))
766767 enum_val_name[bare_name.len..]
767768 else
768769 enum_val_name;
......@@ -1448,7 +1449,7 @@ fn writeEscapedString(buf: []u8, s: []const u8) void {
14481449 var i: usize = 0;
14491450 for (s) |c| {
14501451 const escaped = escapeChar(c, &char_buf);
1451 std.mem.copy(u8, buf[i..], escaped);
1452 mem.copy(u8, buf[i..], escaped);
14521453 i += escaped.len;
14531454 }
14541455}
......@@ -1537,16 +1538,6 @@ fn transCCast(
15371538 builtin_node.rparen_token = try appendToken(rp.c, .RParen, ")");
15381539 return &builtin_node.base;
15391540 }
1540 // TODO
1541 // if (ZigClangQualType_getTypeClass(dst_type) == .Enum and
1542 // ZigClangQualType_getTypeClass(src_type) != .Enum) {
1543 // const builtin_node = try transCreateNodeBuiltinFnCall(rp.c, "@intToEnum");
1544 // try builtin_node.params.push(try transQualType(rp, dst_type, loc));
1545 // _ = try appendToken(rp.c, .Comma, ",");
1546 // try builtin_node.params.push(expr);
1547 // builtin_node.rparen_token = try appendToken(rp.c, .RParen, ")");
1548 // return &builtin_node.base;
1549 // }
15501541 // TODO: maybe widen to increase size
15511542 // TODO: maybe bitcast to change sign
15521543 // TODO: maybe truncate to reduce size
......@@ -2364,9 +2355,9 @@ fn transCreatePostCrement(
23642355fn transCompoundAssignOperator(rp: RestorePoint, scope: *Scope, stmt: *const ZigClangCompoundAssignOperator, used: ResultUsed) TransError!*ast.Node {
23652356 switch (ZigClangCompoundAssignOperator_getOpcode(stmt)) {
23662357 .MulAssign => if (qualTypeHaswrappingOverflow(ZigClangCompoundAssignOperator_getType(stmt)))
2367 return transCreateCompoundAssign(rp, scope, stmt, .AssignMultWrap, .AsteriskPercentEqual, "*%=", .MultWrap, .AsteriskPercent, "*%", used)
2358 return transCreateCompoundAssign(rp, scope, stmt, .AssignMulWrap, .AsteriskPercentEqual, "*%=", .MultWrap, .AsteriskPercent, "*%", used)
23682359 else
2369 return transCreateCompoundAssign(rp, scope, stmt, .AssignMult, .AsteriskEqual, "*=", .Mult, .Asterisk, "*", used),
2360 return transCreateCompoundAssign(rp, scope, stmt, .AssignMul, .AsteriskEqual, "*=", .Mult, .Asterisk, "*", used),
23702361 .AddAssign => if (qualTypeHaswrappingOverflow(ZigClangCompoundAssignOperator_getType(stmt)))
23712362 return transCreateCompoundAssign(rp, scope, stmt, .AssignAddWrap, .PlusPercentEqual, "+%=", .AddWrap, .PlusPercent, "+%", used)
23722363 else
......@@ -2645,13 +2636,13 @@ fn qualTypeIntBitWidth(rp: RestorePoint, qt: ZigClangQualType, source_loc: ZigCl
26452636 const typedef_decl = ZigClangTypedefType_getDecl(typedef_ty);
26462637 const type_name = try rp.c.str(ZigClangDecl_getName_bytes_begin(@ptrCast(*const ZigClangDecl, typedef_decl)));
26472638
2648 if (std.mem.eql(u8, type_name, "uint8_t") or std.mem.eql(u8, type_name, "int8_t")) {
2639 if (mem.eql(u8, type_name, "uint8_t") or mem.eql(u8, type_name, "int8_t")) {
26492640 return 8;
2650 } else if (std.mem.eql(u8, type_name, "uint16_t") or std.mem.eql(u8, type_name, "int16_t")) {
2641 } else if (mem.eql(u8, type_name, "uint16_t") or mem.eql(u8, type_name, "int16_t")) {
26512642 return 16;
2652 } else if (std.mem.eql(u8, type_name, "uint32_t") or std.mem.eql(u8, type_name, "int32_t")) {
2643 } else if (mem.eql(u8, type_name, "uint32_t") or mem.eql(u8, type_name, "int32_t")) {
26532644 return 32;
2654 } else if (std.mem.eql(u8, type_name, "uint64_t") or std.mem.eql(u8, type_name, "int64_t")) {
2645 } else if (mem.eql(u8, type_name, "uint64_t") or mem.eql(u8, type_name, "int64_t")) {
26552646 return 64;
26562647 } else {
26572648 return 0;
......@@ -3176,7 +3167,7 @@ fn transCreateNodeOpaqueType(c: *Context) !*ast.Node {
31763167 return &call_node.base;
31773168}
31783169
3179fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_alias_node: *ast.Node) !*ast.Node {
3170fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_alias: *ast.Node.FnProto) !*ast.Node {
31803171 const scope = &c.global_scope.base;
31813172
31823173 const pub_tok = try appendToken(c, .Keyword_pub, "pub");
......@@ -3185,8 +3176,6 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
31853176 const name_tok = try appendIdentifier(c, name);
31863177 _ = try appendToken(c, .LParen, "(");
31873178
3188 const proto_alias = proto_alias_node.cast(ast.Node.FnProto).?;
3189
31903179 var fn_params = ast.Node.FnProto.ParamList.init(c.a());
31913180 var it = proto_alias.params.iterator(0);
31923181 while (it.next()) |pn| {
......@@ -3948,27 +3937,27 @@ fn isZigPrimitiveType(name: []const u8) bool {
39483937 return true;
39493938 }
39503939 // void is invalid in c so it doesn't need to be checked.
3951 return std.mem.eql(u8, name, "comptime_float") or
3952 std.mem.eql(u8, name, "comptime_int") or
3953 std.mem.eql(u8, name, "bool") or
3954 std.mem.eql(u8, name, "isize") or
3955 std.mem.eql(u8, name, "usize") or
3956 std.mem.eql(u8, name, "f16") or
3957 std.mem.eql(u8, name, "f32") or
3958 std.mem.eql(u8, name, "f64") or
3959 std.mem.eql(u8, name, "f128") or
3960 std.mem.eql(u8, name, "c_longdouble") or
3961 std.mem.eql(u8, name, "noreturn") or
3962 std.mem.eql(u8, name, "type") or
3963 std.mem.eql(u8, name, "anyerror") or
3964 std.mem.eql(u8, name, "c_short") or
3965 std.mem.eql(u8, name, "c_ushort") or
3966 std.mem.eql(u8, name, "c_int") or
3967 std.mem.eql(u8, name, "c_uint") or
3968 std.mem.eql(u8, name, "c_long") or
3969 std.mem.eql(u8, name, "c_ulong") or
3970 std.mem.eql(u8, name, "c_longlong") or
3971 std.mem.eql(u8, name, "c_ulonglong");
3940 return mem.eql(u8, name, "comptime_float") or
3941 mem.eql(u8, name, "comptime_int") or
3942 mem.eql(u8, name, "bool") or
3943 mem.eql(u8, name, "isize") or
3944 mem.eql(u8, name, "usize") or
3945 mem.eql(u8, name, "f16") or
3946 mem.eql(u8, name, "f32") or
3947 mem.eql(u8, name, "f64") or
3948 mem.eql(u8, name, "f128") or
3949 mem.eql(u8, name, "c_longdouble") or
3950 mem.eql(u8, name, "noreturn") or
3951 mem.eql(u8, name, "type") or
3952 mem.eql(u8, name, "anyerror") or
3953 mem.eql(u8, name, "c_short") or
3954 mem.eql(u8, name, "c_ushort") or
3955 mem.eql(u8, name, "c_int") or
3956 mem.eql(u8, name, "c_uint") or
3957 mem.eql(u8, name, "c_long") or
3958 mem.eql(u8, name, "c_ulong") or
3959 mem.eql(u8, name, "c_longlong") or
3960 mem.eql(u8, name, "c_ulonglong");
39723961}
39733962
39743963fn isValidZigIdentifier(name: []const u8) bool {
......@@ -4039,13 +4028,13 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void {
40394028
40404029 var tok_it = tok_list.iterator(0);
40414030 const first_tok = tok_it.next().?;
4042 assert(first_tok.id == .Identifier and std.mem.eql(u8, first_tok.bytes, name));
4031 assert(first_tok.id == .Identifier and mem.eql(u8, first_tok.bytes, name));
40434032 const next = tok_it.peek().?;
40444033 switch (next.id) {
40454034 .Identifier => {
40464035 // if it equals itself, ignore. for example, from stdio.h:
40474036 // #define stdin stdin
4048 if (std.mem.eql(u8, checked_name, next.bytes)) {
4037 if (mem.eql(u8, checked_name, next.bytes)) {
40494038 continue;
40504039 }
40514040 },
......@@ -4493,21 +4482,71 @@ fn tokenSlice(c: *Context, token: ast.TokenIndex) []const u8 {
44934482 return c.source_buffer.toSliceConst()[tok.start..tok.end];
44944483}
44954484
4496fn getFnDecl(c: *Context, ref: *ast.Node) ?*ast.Node {
4497 const init = if (ref.cast(ast.Node.VarDecl)) |v| v.init_node.? else return null;
4498 const name = if (init.cast(ast.Node.Identifier)) |id|
4499 tokenSlice(c, id.token)
4500 else
4501 return null;
4502 // TODO a.b.c
4503 if (c.global_scope.sym_table.get(name)) |kv| {
4504 if (kv.value.cast(ast.Node.VarDecl)) |val| {
4505 if (val.type_node) |type_node| {
4506 if (type_node.cast(ast.Node.PrefixOp)) |casted| {
4507 if (casted.rhs.id == .FnProto) {
4508 return casted.rhs;
4485fn getContainer(c: *Context, node: *ast.Node) ?*ast.Node {
4486 if (node.id == .ContainerDecl) {
4487 return node;
4488 } else if (node.id == .PrefixOp) {
4489 return node;
4490 } else if (node.cast(ast.Node.Identifier)) |ident| {
4491 if (c.global_scope.sym_table.get(tokenSlice(c, ident.token))) |kv| {
4492 if (kv.value.cast(ast.Node.VarDecl)) |var_decl|
4493 return getContainer(c, var_decl.init_node.?);
4494 }
4495 } else if (node.cast(ast.Node.InfixOp)) |infix| {
4496 if (infix.op != .Period)
4497 return null;
4498 if (getContainerTypeOf(c, infix.lhs)) |ty_node| {
4499 if (ty_node.cast(ast.Node.ContainerDecl)) |container| {
4500 var it = container.fields_and_decls.iterator(0);
4501 while (it.next()) |field_ref| {
4502 const field = field_ref.*.cast(ast.Node.ContainerField).?;
4503 const ident = infix.rhs.cast(ast.Node.Identifier).?;
4504 if (mem.eql(u8, tokenSlice(c, field.name_token), tokenSlice(c, ident.token))) {
4505 return getContainer(c, field.type_expr.?);
4506 }
4507 }
4508 }
4509 }
4510 }
4511 return null;
4512}
4513
4514fn getContainerTypeOf(c: *Context, ref: *ast.Node) ?*ast.Node {
4515 if (ref.cast(ast.Node.Identifier)) |ident| {
4516 if (c.global_scope.sym_table.get(tokenSlice(c, ident.token))) |kv| {
4517 if (kv.value.cast(ast.Node.VarDecl)) |var_decl| {
4518 if (var_decl.type_node) |ty|
4519 return getContainer(c, ty);
4520 }
4521 }
4522 } else if (ref.cast(ast.Node.InfixOp)) |infix| {
4523 if (infix.op != .Period)
4524 return null;
4525 if (getContainerTypeOf(c, infix.lhs)) |ty_node| {
4526 if (ty_node.cast(ast.Node.ContainerDecl)) |container| {
4527 var it = container.fields_and_decls.iterator(0);
4528 while (it.next()) |field_ref| {
4529 const field = field_ref.*.cast(ast.Node.ContainerField).?;
4530 const ident = infix.rhs.cast(ast.Node.Identifier).?;
4531 if (mem.eql(u8, tokenSlice(c, field.name_token), tokenSlice(c, ident.token))) {
4532 return getContainer(c, field.type_expr.?);
45094533 }
45104534 }
4535 } else
4536 return ty_node;
4537 }
4538 }
4539 return null;
4540}
4541
4542fn getFnProto(c: *Context, ref: *ast.Node) ?*ast.Node.FnProto {
4543 const init = if (ref.cast(ast.Node.VarDecl)) |v| v.init_node.? else return null;
4544 if (getContainerTypeOf(c, init)) |ty_node| {
4545 if (ty_node.cast(ast.Node.PrefixOp)) |prefix| {
4546 if (prefix.op == .OptionalType) {
4547 if (prefix.rhs.cast(ast.Node.FnProto)) |fn_proto| {
4548 return fn_proto;
4549 }
45114550 }
45124551 }
45134552 }
......@@ -4517,7 +4556,7 @@ fn getFnDecl(c: *Context, ref: *ast.Node) ?*ast.Node {
45174556fn addMacros(c: *Context) !void {
45184557 var macro_it = c.global_scope.macro_table.iterator();
45194558 while (macro_it.next()) |kv| {
4520 if (getFnDecl(c, kv.value)) |proto_node| {
4559 if (getFnProto(c, kv.value)) |proto_node| {
45214560 // If a macro aliases a global variable which is a function pointer, we conclude that
45224561 // the macro is intended to represent a function that assumes the function pointer
45234562 // variable is non-null and calls it.
test/translate_c.zig+8-8
......@@ -887,7 +887,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
887887 \\pub const a = enum_unnamed_1.a;
888888 \\pub const b = enum_unnamed_1.b;
889889 \\pub const c = enum_unnamed_1.c;
890 \\pub const enum_unnamed_1 = extern enum {
890 \\const enum_unnamed_1 = extern enum {
891891 \\ a,
892892 \\ b,
893893 \\ c,
......@@ -896,7 +896,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
896896 \\pub const e = enum_unnamed_2.e;
897897 \\pub const f = enum_unnamed_2.f;
898898 \\pub const g = enum_unnamed_2.g;
899 \\pub const enum_unnamed_2 = extern enum {
899 \\const enum_unnamed_2 = extern enum {
900900 \\ e = 0,
901901 \\ f = 4,
902902 \\ g = 5,
......@@ -905,7 +905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
905905 \\pub const i = enum_unnamed_3.i;
906906 \\pub const j = enum_unnamed_3.j;
907907 \\pub const k = enum_unnamed_3.k;
908 \\pub const enum_unnamed_3 = extern enum {
908 \\const enum_unnamed_3 = extern enum {
909909 \\ i,
910910 \\ j,
911911 \\ k,
......@@ -1027,10 +1027,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
10271027 \\pub extern var glProcs: union_OpenGLProcs;
10281028 ,
10291029 \\pub const glClearPFN = PFNGLCLEARPROC;
1030 // , // TODO
1031 // \\pub inline fn glClearUnion(arg_1: GLbitfield) void {
1032 // \\ return glProcs.gl.Clear.?(arg_1);
1033 // \\}
1030 ,
1031 \\pub inline fn glClearUnion(arg_2: GLbitfield) void {
1032 \\ return glProcs.gl.Clear.?(arg_2);
1033 \\}
10341034 ,
10351035 \\pub const OpenGLProcs = union_OpenGLProcs;
10361036 });
......@@ -1348,7 +1348,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
13481348 , &[_][]const u8{
13491349 \\pub const One = enum_unnamed_1.One;
13501350 \\pub const Two = enum_unnamed_1.Two;
1351 \\pub const enum_unnamed_1 = extern enum {
1351 \\const enum_unnamed_1 = extern enum {
13521352 \\ One,
13531353 \\ Two,
13541354 \\};