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:
Justine Tunney
2020-12-05 12:20:41 -08:00
parent e44a0cf6f8
commit 8da931a7f6
298 changed files with 19493 additions and 11950 deletions

29
third_party/chibicc/test/alloca_test.c vendored Normal file
View File

@@ -0,0 +1,29 @@
#include "third_party/chibicc/test/test.h"
void *fn(int x, void *p, int y) {
return p;
}
int main() {
int i = 0;
char *p1 = alloca(16);
char *p2 = alloca(16);
char *p3 = 1 + (char *)alloca(3) + 1;
p3 -= 2;
char *p4 = fn(1, alloca(16), 3);
ASSERT(16, p1 - p2);
ASSERT(16, p2 - p3);
ASSERT(16, p3 - p4);
memcpy(p1, "0123456789abcdef", 16);
memcpy(p2, "ghijklmnopqrstuv", 16);
memcpy(p3, "wxy", 3);
ASSERT(0, memcmp(p1, "0123456789abcdef", 16));
ASSERT(0, memcmp(p2, "ghijklmnopqrstuv", 16));
ASSERT(0, memcmp(p3, "wxy", 3));
return 0;
}