mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-22 18:40:29 +00:00
Add chibicc
This program popped up on Hacker News recently. It's the only modern compiler I've ever seen that doesn't have dependencies and is easily modified. So I added all of the missing GNU extensions I like to use which means it might be possible soon to build on non-Linux and have third party not vendor gcc binaries.
This commit is contained in:
parent
e44a0cf6f8
commit
8da931a7f6
298 changed files with 19493 additions and 11950 deletions
86
third_party/chibicc/test/vla_test.c
vendored
Normal file
86
third_party/chibicc/test/vla_test.c
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
#include "third_party/chibicc/test/test.h"
|
||||
|
||||
int main() {
|
||||
ASSERT(20, ({
|
||||
int n = 5;
|
||||
int x[n];
|
||||
sizeof(x);
|
||||
}));
|
||||
ASSERT((5 + 1) * (8 * 2) * 4, ({
|
||||
int m = 5, n = 8;
|
||||
int x[m + 1][n * 2];
|
||||
sizeof(x);
|
||||
}));
|
||||
|
||||
ASSERT(8, ({
|
||||
char n = 10;
|
||||
int(*x)[n][n + 2];
|
||||
sizeof(x);
|
||||
}));
|
||||
ASSERT(480, ({
|
||||
char n = 10;
|
||||
int(*x)[n][n + 2];
|
||||
sizeof(*x);
|
||||
}));
|
||||
ASSERT(48, ({
|
||||
char n = 10;
|
||||
int(*x)[n][n + 2];
|
||||
sizeof(**x);
|
||||
}));
|
||||
ASSERT(4, ({
|
||||
char n = 10;
|
||||
int(*x)[n][n + 2];
|
||||
sizeof(***x);
|
||||
}));
|
||||
|
||||
ASSERT(60, ({
|
||||
char n = 3;
|
||||
int x[5][n];
|
||||
sizeof(x);
|
||||
}));
|
||||
ASSERT(12, ({
|
||||
char n = 3;
|
||||
int x[5][n];
|
||||
sizeof(*x);
|
||||
}));
|
||||
|
||||
ASSERT(60, ({
|
||||
char n = 3;
|
||||
int x[n][5];
|
||||
sizeof(x);
|
||||
}));
|
||||
ASSERT(20, ({
|
||||
char n = 3;
|
||||
int x[n][5];
|
||||
sizeof(*x);
|
||||
}));
|
||||
|
||||
ASSERT(0, ({
|
||||
int n = 10;
|
||||
int x[n + 1][n + 6];
|
||||
int *p = x;
|
||||
for (int i = 0; i < sizeof(x) / 4; i++) p[i] = i;
|
||||
x[0][0];
|
||||
}));
|
||||
ASSERT(5, ({
|
||||
int n = 10;
|
||||
int x[n + 1][n + 6];
|
||||
int *p = x;
|
||||
for (int i = 0; i < sizeof(x) / 4; i++) p[i] = i;
|
||||
x[0][5];
|
||||
}));
|
||||
ASSERT(5 * 16 + 2, ({
|
||||
int n = 10;
|
||||
int x[n + 1][n + 6];
|
||||
int *p = x;
|
||||
for (int i = 0; i < sizeof(x) / 4; i++) p[i] = i;
|
||||
x[5][2];
|
||||
}));
|
||||
|
||||
ASSERT(10, ({
|
||||
int n = 5;
|
||||
sizeof(char[2][n]);
|
||||
}));
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue