| ... | @@ -232,7 +232,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -232,7 +232,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 232 | cases.add("use cast param as macro fn return type", | 232 | cases.add("use cast param as macro fn return type", |
| 233 | \\#define MEM_PHYSICAL_TO_K0(x) (void*)((u32)(x) + SYS_BASE_CACHED) | 233 | \\#define MEM_PHYSICAL_TO_K0(x) (void*)((u32)(x) + SYS_BASE_CACHED) |
| 234 | , &[_][]const u8{ | 234 | , &[_][]const u8{ |
| 235 | \\pub fn MEM_PHYSICAL_TO_K0(x: anytype) callconv(.Inline) ?*c_void { | 235 | \\pub inline fn MEM_PHYSICAL_TO_K0(x: anytype) ?*c_void { |
| 236 | \\ return @import("std").meta.cast(?*c_void, @import("std").meta.cast(u32, x) + SYS_BASE_CACHED); | 236 | \\ return @import("std").meta.cast(?*c_void, @import("std").meta.cast(u32, x) + SYS_BASE_CACHED); |
| 237 | \\} | 237 | \\} |
| 238 | }); | 238 | }); |
| ... | @@ -273,7 +273,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -273,7 +273,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 273 | , | 273 | , |
| 274 | \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @boolToInt(@as(c_int, 8) == @as(c_int, 9)); | 274 | \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @boolToInt(@as(c_int, 8) == @as(c_int, 9)); |
| 275 | , | 275 | , |
| 276 | \\pub fn _AL_READ3BYTES(p: anytype) callconv(.Inline) @TypeOf((@import("std").meta.cast([*c]u8, p).* | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16))) { | 276 | \\pub inline fn _AL_READ3BYTES(p: anytype) @TypeOf((@import("std").meta.cast([*c]u8, p).* | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16))) { |
| 277 | \\ return (@import("std").meta.cast([*c]u8, p).* | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16)); | 277 | \\ return (@import("std").meta.cast([*c]u8, p).* | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16)); |
| 278 | \\} | 278 | \\} |
| 279 | }); | 279 | }); |
| ... | @@ -345,7 +345,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -345,7 +345,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 345 | \\}; | 345 | \\}; |
| 346 | \\pub const Color = struct_Color; | 346 | \\pub const Color = struct_Color; |
| 347 | , | 347 | , |
| 348 | \\pub fn CLITERAL(type_1: anytype) callconv(.Inline) @TypeOf(type_1) { | 348 | \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) { |
| 349 | \\ return type_1; | 349 | \\ return type_1; |
| 350 | \\} | 350 | \\} |
| 351 | , | 351 | , |
| ... | @@ -380,7 +380,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -380,7 +380,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 380 | cases.add("correct semicolon after infixop", | 380 | cases.add("correct semicolon after infixop", |
| 381 | \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) | 381 | \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) |
| 382 | , &[_][]const u8{ | 382 | , &[_][]const u8{ |
| 383 | \\pub fn __ferror_unlocked_body(_fp: anytype) callconv(.Inline) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) { | 383 | \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) { |
| 384 | \\ return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0); | 384 | \\ return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0); |
| 385 | \\} | 385 | \\} |
| 386 | }); | 386 | }); |
| ... | @@ -389,7 +389,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -389,7 +389,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 389 | \\#define FOO(x) ((x >= 0) + (x >= 0)) | 389 | \\#define FOO(x) ((x >= 0) + (x >= 0)) |
| 390 | \\#define BAR 1 && 2 > 4 | 390 | \\#define BAR 1 && 2 > 4 |
| 391 | , &[_][]const u8{ | 391 | , &[_][]const u8{ |
| 392 | \\pub fn FOO(x: anytype) callconv(.Inline) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) { | 392 | \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) { |
| 393 | \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0)); | 393 | \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0)); |
| 394 | \\} | 394 | \\} |
| 395 | , | 395 | , |
| ... | @@ -438,7 +438,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -438,7 +438,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 438 | \\ break :blk bar; | 438 | \\ break :blk bar; |
| 439 | \\}; | 439 | \\}; |
| 440 | , | 440 | , |
| 441 | \\pub fn bar(x: anytype) callconv(.Inline) @TypeOf(baz(@as(c_int, 1), @as(c_int, 2))) { | 441 | \\pub inline fn bar(x: anytype) @TypeOf(baz(@as(c_int, 1), @as(c_int, 2))) { |
| 442 | \\ return blk: { | 442 | \\ return blk: { |
| 443 | \\ _ = &x; | 443 | \\ _ = &x; |
| 444 | \\ _ = @as(c_int, 3); | 444 | \\ _ = @as(c_int, 3); |
| ... | @@ -1782,13 +1782,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1782,13 +1782,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1782 | , &[_][]const u8{ | 1782 | , &[_][]const u8{ |
| 1783 | \\pub extern var fn_ptr: ?fn () callconv(.C) void; | 1783 | \\pub extern var fn_ptr: ?fn () callconv(.C) void; |
| 1784 | , | 1784 | , |
| 1785 | \\pub fn foo() callconv(.Inline) void { | 1785 | \\pub inline fn foo() void { |
| 1786 | \\ return fn_ptr.?(); | 1786 | \\ return fn_ptr.?(); |
| 1787 | \\} | 1787 | \\} |
| 1788 | , | 1788 | , |
| 1789 | \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8; | 1789 | \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8; |
| 1790 | , | 1790 | , |
| 1791 | \\pub fn bar(arg_1: c_int, arg_2: f32) callconv(.Inline) u8 { | 1791 | \\pub inline fn bar(arg_1: c_int, arg_2: f32) u8 { |
| 1792 | \\ return fn_ptr2.?(arg_1, arg_2); | 1792 | \\ return fn_ptr2.?(arg_1, arg_2); |
| 1793 | \\} | 1793 | \\} |
| 1794 | }); | 1794 | }); |
| ... | @@ -1821,7 +1821,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1821,7 +1821,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1821 | , | 1821 | , |
| 1822 | \\pub const glClearPFN = PFNGLCLEARPROC; | 1822 | \\pub const glClearPFN = PFNGLCLEARPROC; |
| 1823 | , | 1823 | , |
| 1824 | \\pub fn glClearUnion(arg_2: GLbitfield) callconv(.Inline) void { | 1824 | \\pub inline fn glClearUnion(arg_2: GLbitfield) void { |
| 1825 | \\ return glProcs.gl.Clear.?(arg_2); | 1825 | \\ return glProcs.gl.Clear.?(arg_2); |
| 1826 | \\} | 1826 | \\} |
| 1827 | , | 1827 | , |
| ... | @@ -1842,15 +1842,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1842,15 +1842,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1842 | , &[_][]const u8{ | 1842 | , &[_][]const u8{ |
| 1843 | \\pub extern var c: c_int; | 1843 | \\pub extern var c: c_int; |
| 1844 | , | 1844 | , |
| 1845 | \\pub fn BASIC(c_1: anytype) callconv(.Inline) @TypeOf(c_1 * @as(c_int, 2)) { | 1845 | \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * @as(c_int, 2)) { |
| 1846 | \\ return c_1 * @as(c_int, 2); | 1846 | \\ return c_1 * @as(c_int, 2); |
| 1847 | \\} | 1847 | \\} |
| 1848 | , | 1848 | , |
| 1849 | \\pub fn FOO(L: anytype, b: anytype) callconv(.Inline) @TypeOf(L + b) { | 1849 | \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) { |
| 1850 | \\ return L + b; | 1850 | \\ return L + b; |
| 1851 | \\} | 1851 | \\} |
| 1852 | , | 1852 | , |
| 1853 | \\pub fn BAR() callconv(.Inline) @TypeOf(c * c) { | 1853 | \\pub inline fn BAR() @TypeOf(c * c) { |
| 1854 | \\ return c * c; | 1854 | \\ return c * c; |
| 1855 | \\} | 1855 | \\} |
| 1856 | }); | 1856 | }); |
| ... | @@ -2549,7 +2549,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2549,7 +2549,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2549 | cases.add("macro call", | 2549 | cases.add("macro call", |
| 2550 | \\#define CALL(arg) bar(arg) | 2550 | \\#define CALL(arg) bar(arg) |
| 2551 | , &[_][]const u8{ | 2551 | , &[_][]const u8{ |
| 2552 | \\pub fn CALL(arg: anytype) callconv(.Inline) @TypeOf(bar(arg)) { | 2552 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) { |
| 2553 | \\ return bar(arg); | 2553 | \\ return bar(arg); |
| 2554 | \\} | 2554 | \\} |
| 2555 | }); | 2555 | }); |
| ... | @@ -2557,7 +2557,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2557,7 +2557,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2557 | cases.add("macro call with no args", | 2557 | cases.add("macro call with no args", |
| 2558 | \\#define CALL(arg) bar() | 2558 | \\#define CALL(arg) bar() |
| 2559 | , &[_][]const u8{ | 2559 | , &[_][]const u8{ |
| 2560 | \\pub fn CALL(arg: anytype) callconv(.Inline) @TypeOf(bar()) { | 2560 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar()) { |
| 2561 | \\ return bar(); | 2561 | \\ return bar(); |
| 2562 | \\} | 2562 | \\} |
| 2563 | }); | 2563 | }); |
| ... | @@ -3120,7 +3120,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3120,7 +3120,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3120 | \\#define BAR (void*) a | 3120 | \\#define BAR (void*) a |
| 3121 | \\#define BAZ (uint32_t)(2) | 3121 | \\#define BAZ (uint32_t)(2) |
| 3122 | , &[_][]const u8{ | 3122 | , &[_][]const u8{ |
| 3123 | \\pub fn FOO(bar: anytype) callconv(.Inline) @TypeOf(baz(@import("std").meta.cast(?*c_void, baz))) { | 3123 | \\pub inline fn FOO(bar: anytype) @TypeOf(baz(@import("std").meta.cast(?*c_void, baz))) { |
| 3124 | \\ return baz(@import("std").meta.cast(?*c_void, baz)); | 3124 | \\ return baz(@import("std").meta.cast(?*c_void, baz)); |
| 3125 | \\} | 3125 | \\} |
| 3126 | , | 3126 | , |
| ... | @@ -3160,11 +3160,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3160,11 +3160,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3160 | \\#define MIN(a, b) ((b) < (a) ? (b) : (a)) | 3160 | \\#define MIN(a, b) ((b) < (a) ? (b) : (a)) |
| 3161 | \\#define MAX(a, b) ((b) > (a) ? (b) : (a)) | 3161 | \\#define MAX(a, b) ((b) > (a) ? (b) : (a)) |
| 3162 | , &[_][]const u8{ | 3162 | , &[_][]const u8{ |
| 3163 | \\pub fn MIN(a: anytype, b: anytype) callconv(.Inline) @TypeOf(if (b < a) b else a) { | 3163 | \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) { |
| 3164 | \\ return if (b < a) b else a; | 3164 | \\ return if (b < a) b else a; |
| 3165 | \\} | 3165 | \\} |
| 3166 | , | 3166 | , |
| 3167 | \\pub fn MAX(a: anytype, b: anytype) callconv(.Inline) @TypeOf(if (b > a) b else a) { | 3167 | \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) { |
| 3168 | \\ return if (b > a) b else a; | 3168 | \\ return if (b > a) b else a; |
| 3169 | \\} | 3169 | \\} |
| 3170 | }); | 3170 | }); |
| ... | @@ -3351,7 +3351,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3351,7 +3351,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3351 | \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen) | 3351 | \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen) |
| 3352 | \\ | 3352 | \\ |
| 3353 | , &[_][]const u8{ | 3353 | , &[_][]const u8{ |
| 3354 | \\pub fn DefaultScreen(dpy: anytype) callconv(.Inline) @TypeOf(@import("std").meta.cast(_XPrivDisplay, dpy).*.default_screen) { | 3354 | \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf(@import("std").meta.cast(_XPrivDisplay, dpy).*.default_screen) { |
| 3355 | \\ return @import("std").meta.cast(_XPrivDisplay, dpy).*.default_screen; | 3355 | \\ return @import("std").meta.cast(_XPrivDisplay, dpy).*.default_screen; |
| 3356 | \\} | 3356 | \\} |
| 3357 | }); | 3357 | }); |
| ... | @@ -3501,17 +3501,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3501,17 +3501,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3501 | }); | 3501 | }); |
| 3502 | | 3502 | |
| 3503 | cases.add("global assembly", | 3503 | cases.add("global assembly", |
| 3504 | \\__asm__(".globl func\n\t" | 3504 | \\__asm__(".globl func\n\t" |
| 3505 | \\ ".type func, @function\n\t" | 3505 | \\ ".type func, @function\n\t" |
| 3506 | \\ "func:\n\t" | 3506 | \\ "func:\n\t" |
| 3507 | \\ ".cfi_startproc\n\t" | 3507 | \\ ".cfi_startproc\n\t" |
| 3508 | \\ "movl $42, %eax\n\t" | 3508 | \\ "movl $42, %eax\n\t" |
| 3509 | \\ "ret\n\t" | 3509 | \\ "ret\n\t" |
| 3510 | \\ ".cfi_endproc"); | 3510 | \\ ".cfi_endproc"); |
| 3511 | , &[_][]const u8{ | 3511 | , &[_][]const u8{ |
| 3512 | \\comptime { | 3512 | \\comptime { |
| 3513 | \\ asm (".globl func\n\t.type func, @function\n\tfunc:\n\t.cfi_startproc\n\tmovl $42, %eax\n\tret\n\t.cfi_endproc"); | 3513 | \\ asm (".globl func\n\t.type func, @function\n\tfunc:\n\t.cfi_startproc\n\tmovl $42, %eax\n\tret\n\t.cfi_endproc"); |
| 3514 | \\} | 3514 | \\} |
| 3515 | }); | 3515 | }); |
| 3516 | | 3516 | |
| 3517 | cases.add("Demote function that initializes opaque struct", | 3517 | cases.add("Demote function that initializes opaque struct", |