-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some already processed test cases
- Loading branch information
Showing
45 changed files
with
748 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
int main() { | ||
int i = 2; | ||
float f = 3.2f; | ||
|
||
i += 1.7; | ||
if (i != 3) return 1; | ||
i += f; | ||
if (i != 6) return 2; | ||
|
||
|
||
f += 2UL; | ||
if (f <= 5.1999 || f >= 5.2001) return 3; | ||
f += i; | ||
if (f <= 11.1999 || f >= 11.2001) return 4; | ||
|
||
return 0; | ||
} | ||
|
||
// run | ||
// expect=fail |
21 changes: 21 additions & 0 deletions
21
test/cases/run/compound_assignments_with_pointer_arithmetic.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
int main() { | ||
const char *s = "forgreatjustice"; | ||
unsigned int add = 1; | ||
|
||
s += add; | ||
if (*s != 'o') return 1; | ||
|
||
s += 1UL; | ||
if (*s != 'r') return 2; | ||
|
||
const char *s2 = (s += add); | ||
if (*s2 != 'g') return 3; | ||
|
||
s2 -= add; | ||
if (*s2 != 'r') return 4; | ||
|
||
return 0; | ||
} | ||
|
||
// run | ||
// expect=fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <stdlib.h> | ||
int main(void) { | ||
int i = 0; | ||
*&i = 42; | ||
if (i != 42) abort(); | ||
return 0; | ||
} | ||
|
||
// run | ||
// expect=fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <stdbool.h> | ||
|
||
int main() { | ||
float f = 2.0f; | ||
bool b = (bool) f; | ||
return 0; | ||
} | ||
|
||
// run | ||
// expect=fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const int ev = 40; | ||
|
||
static int func(void) | ||
{ | ||
typedef int test_type_t; | ||
extern const test_type_t ev; | ||
// Ensure mangled name is also being used for conditions and loops, see #20828 | ||
if (ev == 0); | ||
while (ev == 0); | ||
do; while (ev == 0); | ||
return ev + 2; | ||
} | ||
|
||
int main() | ||
{ | ||
if (func() != 42) | ||
return 1; | ||
return 0; | ||
} | ||
|
||
// run | ||
// expect=fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
int main() { | ||
float f = (float)(10.0f > 1.0f); | ||
return 0; | ||
} | ||
|
||
// run | ||
// expect=fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
_Static_assert(1 == 1, ""); | ||
|
||
// translate | ||
// target=x86_64-linux | ||
// | ||
// tmp.c:1:1: warning: ignoring _Static_assert declaration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
__attribute__ ((aligned(128))) | ||
extern char my_array[16]; | ||
__attribute__ ((aligned(128))) | ||
void my_fn(void) { } | ||
void other_fn(void) { | ||
char ARR[16] __attribute__ ((aligned (16))); | ||
} | ||
|
||
// translate | ||
// expect=fail | ||
// | ||
// pub extern var my_array: [16]u8 align(128); | ||
// pub export fn my_fn() align(128) void {} | ||
// pub export fn other_fn() void { | ||
// var ARR: [16]u8 align(16) = undefined; | ||
// _ = &ARR; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
void assert(int x) {} | ||
#define FOO assert(0 && "error message") | ||
|
||
// translate | ||
// expect=fail | ||
// | ||
// pub const FOO = assert((@as(c_int, 0) != 0) and (@intFromPtr("error message") != 0)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
typedef _Atomic(int) AtomicInt; | ||
|
||
// translate | ||
// target=x86_64-linux | ||
// | ||
// tmp.c:1:22: warning: unsupported type: '_Atomic(int)' | ||
// pub const AtomicInt = @compileError("unable to resolve typedef child type"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
struct Bar; | ||
|
||
struct Foo { | ||
struct Bar *next; | ||
}; | ||
|
||
struct Bar { | ||
struct Foo *next; | ||
}; | ||
|
||
// translate | ||
// expect=fail | ||
// | ||
// pub const struct_Bar = extern struct { | ||
// next: [*c]struct_Foo = @import("std").mem.zeroes([*c]struct_Foo), | ||
// }; | ||
// | ||
// pub const struct_Foo = extern struct { | ||
// next: [*c]struct_Bar = @import("std").mem.zeroes([*c]struct_Bar), | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
typedef struct Bar Bar; | ||
typedef struct Foo Foo; | ||
|
||
struct Foo { | ||
Foo *a; | ||
}; | ||
|
||
struct Bar { | ||
Foo *a; | ||
}; | ||
|
||
// translate | ||
// expect=fail | ||
// | ||
// pub const struct_Foo = extern struct { | ||
// a: [*c]Foo = @import("std").mem.zeroes([*c]Foo), | ||
// }; | ||
// | ||
// pub const Foo = struct_Foo; | ||
// | ||
// pub const struct_Bar = extern struct { | ||
// a: [*c]Foo = @import("std").mem.zeroes([*c]Foo), | ||
// }; | ||
// | ||
// pub const Bar = struct_Bar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
; | ||
|
||
//translate | ||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
union U { | ||
int x; | ||
long y; | ||
}; | ||
|
||
void foo(void) { | ||
union U u = {}; | ||
} | ||
// translate | ||
// target=x86_64-linux | ||
// expect=fail | ||
// | ||
// pub const union_U = extern union { | ||
// x: c_int, | ||
// y: c_long, | ||
// }; | ||
// pub export fn foo() void { | ||
// var u: union_U = @import("std").mem.zeroes(union_U); | ||
// _ = &u; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
enum Foo { | ||
FooA = 2, | ||
FooB = 5, | ||
Foo1, | ||
}; | ||
|
||
// translate | ||
// target=x86_64-windows-msvc | ||
// expect=fail | ||
// | ||
// pub const FooA: c_int = 2; | ||
// pub const FooB: c_int = 5; | ||
// pub const Foo1: c_int = 6; | ||
// pub const enum_Foo = c_int; | ||
// | ||
// pub const Foo = enum_Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
enum Foo { | ||
FooA = 2, | ||
FooB = 5, | ||
Foo1, | ||
}; | ||
|
||
// translate | ||
// target=x86_64-linux | ||
// | ||
// pub const FooA: c_int = 2; | ||
// pub const FooB: c_int = 5; | ||
// pub const Foo1: c_int = 6; | ||
// pub const enum_Foo = c_uint; | ||
// | ||
// pub const Foo = enum_Foo; |
18 changes: 18 additions & 0 deletions
18
test/cases/translate/field_access_is_grouped_if_necessary.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
unsigned long foo(unsigned long x) { | ||
return ((union{unsigned long _x}){x})._x; | ||
} | ||
|
||
// translate | ||
// expect=fail | ||
// | ||
// pub export fn foo(arg_x: c_ulong) c_ulong { | ||
// var x = arg_x; | ||
// _ = &x; | ||
// const union_unnamed_1 = extern union { | ||
// _x: c_ulong, | ||
// }; | ||
// _ = &union_unnamed_1; | ||
// return (union_unnamed_1{ | ||
// ._x = x, | ||
// })._x; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void (f0) (void *L); | ||
void ((f1)) (void *L); | ||
void (((f2))) (void *L); | ||
|
||
// translate | ||
// | ||
// pub extern fn f0(L: ?*anyopaque) void; | ||
// pub extern fn f1(L: ?*anyopaque) void; | ||
// pub extern fn f2(L: ?*anyopaque) void; |
15 changes: 15 additions & 0 deletions
15
test/cases/translate/global_struct_whose_default_name_conflicts_with_global_is_mangled.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
struct foo { | ||
int x; | ||
}; | ||
const char *struct_foo = "hello world"; | ||
|
||
// translate | ||
// expect=fail | ||
// | ||
// pub const struct_foo_1 = extern struct { | ||
// x: c_int = @import("std").mem.zeroes(c_int), | ||
// }; | ||
// | ||
// pub const foo = struct_foo_1; | ||
// | ||
// pub export var struct_foo: [*c]const u8 = "hello world"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
struct __attribute__((packed)) bar { | ||
short a; | ||
float b; | ||
double c; | ||
short x; | ||
float y; | ||
double z; | ||
}; | ||
|
||
// translate | ||
// | ||
// pub const struct_bar = extern struct { | ||
// a: c_short align(1) = @import("std").mem.zeroes(c_short), | ||
// b: f32 align(1) = @import("std").mem.zeroes(f32), | ||
// c: f64 align(1) = @import("std").mem.zeroes(f64), | ||
// x: c_short align(1) = @import("std").mem.zeroes(c_short), | ||
// y: f32 align(1) = @import("std").mem.zeroes(f32), | ||
// z: f64 align(1) = @import("std").mem.zeroes(f64), | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#define bar() "" | ||
#define FOO bar() "," bar() | ||
|
||
// translate | ||
// target=x86_64-linux | ||
// expect=fail | ||
// | ||
// pub inline fn bar() @TypeOf("") { | ||
// return ""; | ||
// } | ||
// pub const FOO = bar() ++ "," ++ bar(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extern float foo; | ||
#define FOO_TWICE foo * 2.0f | ||
#define FOO_NEGATIVE -foo | ||
|
||
#define BAR 10.0f | ||
#define BAR_TWICE BAR * 2.0f | ||
|
||
// translate | ||
// expect=fail | ||
// | ||
// pub extern var foo: f32; | ||
// | ||
// pub inline fn FOO_TWICE() @TypeOf(foo * @as(f32, 2.0)) { | ||
// return foo * @as(f32, 2.0); | ||
// } | ||
// | ||
// pub inline fn FOO_NEGATIVE() @TypeOf(-foo) { | ||
// return -foo; | ||
// } | ||
// pub const BAR = @as(f32, 10.0); | ||
// pub const BAR_TWICE = BAR * @as(f32, 2.0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
void foo(void) __attribute__((noreturn)); | ||
|
||
// translate | ||
// | ||
// pub extern fn foo() noreturn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// NOTE: The nested struct is *not* packed/aligned, | ||
// even though the parent struct is | ||
// this is consistent with GCC docs | ||
union Foo{ | ||
short x; | ||
double y; | ||
struct { | ||
int b; | ||
} z; | ||
} __attribute__((packed)); | ||
|
||
// translate | ||
// | ||
// const struct_unnamed_1 = extern struct { | ||
// b: c_int = @import("std").mem.zeroes(c_int), | ||
// }; | ||
// | ||
// pub const union_Foo = extern union { | ||
// x: c_short align(1), | ||
// y: f64 align(1), | ||
// z: struct_unnamed_1 align(1), | ||
// }; | ||
// | ||
// pub const Foo = union_Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
union Foo { | ||
short x; | ||
double y; | ||
} __attribute__((packed)); | ||
|
||
// translate | ||
// | ||
// pub const union_Foo = extern union { | ||
// x: c_short align(1), | ||
// y: f64 align(1), | ||
// }; | ||
// | ||
// pub const Foo = union_Foo; |
Oops, something went wrong.