| ... | ... | @@ -3371,6 +3371,7 @@ fn expectContainerDeclAuto(p: *Parse) !Node.Index { |
| 3371 | 3371 | /// Give a helpful error message for those transitioning from |
| 3372 | 3372 | /// C's 'struct Foo {};' to Zig's 'const Foo = struct {};'. |
| 3373 | 3373 | fn parseCStyleContainer(p: *Parse) Error!bool { |
| 3374 | if (!p.recover) return false; |
| 3374 | 3375 | const main_token = p.tok_i; |
| 3375 | 3376 | switch (p.tokenTag(p.tok_i)) { |
| 3376 | 3377 | .keyword_enum, .keyword_union, .keyword_struct => {}, |
| ... | ... | @@ -3436,10 +3437,13 @@ fn parseParamDeclList(p: *Parse) !SmallSpan { |
| 3436 | 3437 | _ = try p.expectToken(.l_paren); |
| 3437 | 3438 | const scratch_top = p.scratch.items.len; |
| 3438 | 3439 | defer p.scratch.shrinkRetainingCapacity(scratch_top); |
| 3439 | | var varargs: union(enum) { none, seen, nonfinal: TokenIndex } = .none; |
| 3440 | var varargs: enum { none, seen, err } = .none; |
| 3440 | 3441 | while (true) { |
| 3441 | 3442 | if (p.eatToken(.r_paren)) |_| break; |
| 3442 | | if (varargs == .seen) varargs = .{ .nonfinal = p.tok_i }; |
| 3443 | if (varargs == .seen) { |
| 3444 | try p.warnMsg(.{ .tag = .varargs_nonfinal, .token = p.tok_i }); |
| 3445 | varargs = .err; |
| 3446 | } |
| 3443 | 3447 | const opt_param = try p.expectParamDecl(); |
| 3444 | 3448 | if (opt_param) |param| { |
| 3445 | 3449 | try p.scratch.append(p.gpa, param); |
| ... | ... | @@ -3457,9 +3461,6 @@ fn parseParamDeclList(p: *Parse) !SmallSpan { |
| 3457 | 3461 | else => try p.warn(.expected_comma_after_param), |
| 3458 | 3462 | } |
| 3459 | 3463 | } |
| 3460 | | if (varargs == .nonfinal) { |
| 3461 | | try p.warnMsg(.{ .tag = .varargs_nonfinal, .token = varargs.nonfinal }); |
| 3462 | | } |
| 3463 | 3464 | const params = p.scratch.items[scratch_top..]; |
| 3464 | 3465 | return switch (params.len) { |
| 3465 | 3466 | 0 => .{ .zero_or_one = .none }, |