mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-22 02:20:31 +00:00
Use long
as implicit type in chibicc
This makes it possible to write 64-bit C without headers and prototypes.
This commit is contained in:
parent
42ba9901e4
commit
d3cf9d4ef1
3 changed files with 77 additions and 5 deletions
64
third_party/chibicc/test/implicit_test.c
vendored
Normal file
64
third_party/chibicc/test/implicit_test.c
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
add(x, y) {
|
||||
return x + y;
|
||||
}
|
||||
|
||||
implicit_functions_are_long() {
|
||||
if (add(0xffffffff, 0xffffffff) != 0x0001fffffffe) {
|
||||
__builtin_trap();
|
||||
}
|
||||
}
|
||||
|
||||
external_functions_are_long() {
|
||||
if (_bsrl(0x0001000000000000) != 48) {
|
||||
__builtin_trap();
|
||||
}
|
||||
}
|
||||
|
||||
auto_variables_are_long() {
|
||||
auto x, y, z;
|
||||
x = 0x0101fffffffe;
|
||||
y = 0x0201fffffffe;
|
||||
z = x + y;
|
||||
if (z != 0x0303fffffffc) {
|
||||
__builtin_trap();
|
||||
}
|
||||
}
|
||||
|
||||
static_variables_are_long() {
|
||||
static x, y, z;
|
||||
x = 0x0101fffffffe;
|
||||
y = 0x0201fffffffe;
|
||||
z = x + y;
|
||||
if (z != 0x0303fffffffc) {
|
||||
__builtin_trap();
|
||||
}
|
||||
}
|
||||
|
||||
x_ = 0x0101fffffffe;
|
||||
y_ = 0x0201fffffffe;
|
||||
z_;
|
||||
|
||||
globo_variables_are_long() {
|
||||
z_ = x_ + y_;
|
||||
if (z_ != 0x0303fffffffc) {
|
||||
__builtin_trap();
|
||||
}
|
||||
}
|
||||
|
||||
implicit_function_string() {
|
||||
auto lol = strdup("hello");
|
||||
if (strlen(lol) != 5) {
|
||||
__builtin_trap();
|
||||
}
|
||||
free(lol);
|
||||
}
|
||||
|
||||
main() {
|
||||
ShowCrashReports();
|
||||
implicit_functions_are_long();
|
||||
external_functions_are_long();
|
||||
auto_variables_are_long();
|
||||
static_variables_are_long();
|
||||
globo_variables_are_long();
|
||||
implicit_function_string();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue