mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 15:42:49 +00:00
fix c tokenizer bug
This commit is contained in:
parent
9e1afdc234
commit
b15958c557
@ -616,6 +616,7 @@ pub const Tokenizer = struct {
|
|||||||
},
|
},
|
||||||
.BackSlash => switch (c) {
|
.BackSlash => switch (c) {
|
||||||
'\n' => {
|
'\n' => {
|
||||||
|
result.start = self.index + 1;
|
||||||
state = .Start;
|
state = .Start;
|
||||||
},
|
},
|
||||||
'\r' => {
|
'\r' => {
|
||||||
@ -631,6 +632,7 @@ pub const Tokenizer = struct {
|
|||||||
},
|
},
|
||||||
.BackSlashCr => switch (c) {
|
.BackSlashCr => switch (c) {
|
||||||
'\n' => {
|
'\n' => {
|
||||||
|
result.start = self.index + 1;
|
||||||
state = .Start;
|
state = .Start;
|
||||||
},
|
},
|
||||||
else => {
|
else => {
|
||||||
|
@ -3,6 +3,13 @@ const builtin = @import("builtin");
|
|||||||
const Target = @import("std").Target;
|
const Target = @import("std").Target;
|
||||||
|
|
||||||
pub fn addCases(cases: *tests.TranslateCContext) void {
|
pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||||
|
cases.add("macro line continuation",
|
||||||
|
\\#define FOO -\
|
||||||
|
\\BAR
|
||||||
|
, &[_][]const u8{
|
||||||
|
\\pub const FOO = -BAR;
|
||||||
|
});
|
||||||
|
|
||||||
cases.add("function prototype translated as optional",
|
cases.add("function prototype translated as optional",
|
||||||
\\typedef void (*fnptr_ty)(void);
|
\\typedef void (*fnptr_ty)(void);
|
||||||
\\typedef __attribute__((cdecl)) void (*fnptr_attr_ty)(void);
|
\\typedef __attribute__((cdecl)) void (*fnptr_attr_ty)(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user