mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +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
160
third_party/chibicc/test/attribute_test.c
vendored
Normal file
160
third_party/chibicc/test/attribute_test.c
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
#include "third_party/chibicc/test/test.h"
|
||||
|
||||
int main() {
|
||||
ASSERT(5, ({
|
||||
struct {
|
||||
char a;
|
||||
int b;
|
||||
} __attribute__((packed)) x;
|
||||
sizeof(x);
|
||||
}));
|
||||
ASSERT(0, offsetof(
|
||||
struct __attribute__((packed)) {
|
||||
char a;
|
||||
int b;
|
||||
},
|
||||
a));
|
||||
ASSERT(1, offsetof(
|
||||
struct __attribute__((packed)) {
|
||||
char a;
|
||||
int b;
|
||||
},
|
||||
b));
|
||||
|
||||
ASSERT(5, ({
|
||||
struct __attribute__((packed)) {
|
||||
char a;
|
||||
int b;
|
||||
} x;
|
||||
sizeof(x);
|
||||
}));
|
||||
ASSERT(0, offsetof(
|
||||
struct {
|
||||
char a;
|
||||
int b;
|
||||
} __attribute__((packed)),
|
||||
a));
|
||||
ASSERT(1, offsetof(
|
||||
struct {
|
||||
char a;
|
||||
int b;
|
||||
} __attribute__((packed)),
|
||||
b));
|
||||
|
||||
ASSERT(9, ({
|
||||
typedef struct {
|
||||
char a;
|
||||
int b[2];
|
||||
} __attribute__((packed)) T;
|
||||
sizeof(T);
|
||||
}));
|
||||
ASSERT(9, ({
|
||||
typedef struct __attribute__((packed)) {
|
||||
char a;
|
||||
int b[2];
|
||||
} T;
|
||||
sizeof(T);
|
||||
}));
|
||||
|
||||
ASSERT(1, offsetof(
|
||||
struct __attribute__((packed)) T {
|
||||
char a;
|
||||
int b[2];
|
||||
},
|
||||
b));
|
||||
ASSERT(1, _Alignof(struct __attribute__((packed)) {
|
||||
char a;
|
||||
int b[2];
|
||||
}));
|
||||
|
||||
ASSERT(8, ({
|
||||
struct __attribute__((aligned(8))) {
|
||||
int a;
|
||||
} x;
|
||||
_Alignof(x);
|
||||
}));
|
||||
ASSERT(8, ({
|
||||
struct {
|
||||
int a;
|
||||
} __attribute__((aligned(8))) x;
|
||||
_Alignof(x);
|
||||
}));
|
||||
|
||||
ASSERT(8, ({
|
||||
struct __attribute__((aligned(8), packed)) {
|
||||
char a;
|
||||
int b;
|
||||
} x;
|
||||
_Alignof(x);
|
||||
}));
|
||||
ASSERT(8, ({
|
||||
struct {
|
||||
char a;
|
||||
int b;
|
||||
} __attribute__((aligned(8), packed)) x;
|
||||
_Alignof(x);
|
||||
}));
|
||||
ASSERT(1, offsetof(
|
||||
struct __attribute__((aligned(8), packed)) {
|
||||
char a;
|
||||
int b;
|
||||
},
|
||||
b));
|
||||
ASSERT(1, offsetof(
|
||||
struct {
|
||||
char a;
|
||||
int b;
|
||||
} __attribute__((aligned(8), packed)),
|
||||
b));
|
||||
|
||||
ASSERT(8, ({
|
||||
struct __attribute__((aligned(8))) __attribute__((packed)) {
|
||||
char a;
|
||||
int b;
|
||||
} x;
|
||||
_Alignof(x);
|
||||
}));
|
||||
ASSERT(8, ({
|
||||
struct {
|
||||
char a;
|
||||
int b;
|
||||
} __attribute__((aligned(8))) __attribute__((packed)) x;
|
||||
_Alignof(x);
|
||||
}));
|
||||
ASSERT(1, offsetof(
|
||||
struct __attribute__((aligned(8))) __attribute__((packed)) {
|
||||
char a;
|
||||
int b;
|
||||
},
|
||||
b));
|
||||
ASSERT(1, offsetof(
|
||||
struct {
|
||||
char a;
|
||||
int b;
|
||||
} __attribute__((aligned(8))) __attribute__((packed)),
|
||||
b));
|
||||
|
||||
ASSERT(8, ({
|
||||
struct __attribute__((aligned(8))) {
|
||||
char a;
|
||||
int b;
|
||||
} __attribute__((packed)) x;
|
||||
_Alignof(x);
|
||||
}));
|
||||
ASSERT(1, offsetof(
|
||||
struct __attribute__((aligned(8))) {
|
||||
char a;
|
||||
int b;
|
||||
} __attribute__((packed)),
|
||||
b));
|
||||
|
||||
ASSERT(16, ({
|
||||
struct __attribute__((aligned(8 + 8))) {
|
||||
char a;
|
||||
int b;
|
||||
} x;
|
||||
_Alignof(x);
|
||||
}));
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue