mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 00:08:30 +00:00
Make minor improvements
This commit is contained in:
parent
04caf6f9ad
commit
95b142e4e5
95 changed files with 3818 additions and 2760 deletions
23
third_party/chibicc/test/bitfield_test.c
vendored
23
third_party/chibicc/test/bitfield_test.c
vendored
|
@ -1,5 +1,7 @@
|
|||
#include "third_party/chibicc/test/test.h"
|
||||
|
||||
#define TYPE_SIGNED(type) (((type)-1) < 0)
|
||||
|
||||
struct {
|
||||
char a;
|
||||
int b : 5;
|
||||
|
@ -7,6 +9,27 @@ struct {
|
|||
} g45 = {1, 2, 3}, g46 = {};
|
||||
|
||||
int main() {
|
||||
|
||||
/* NOTE: Consistent w/ GCC (but MSVC would fail this) */
|
||||
ASSERT(1, 2 == ({
|
||||
struct {
|
||||
enum { a, b, c } e : 2;
|
||||
} x = {
|
||||
.e = 2,
|
||||
};
|
||||
x.e;
|
||||
}));
|
||||
|
||||
/* NOTE: GCC forbids typeof(bitfield). */
|
||||
ASSERT(0, ({
|
||||
struct {
|
||||
enum { a, b, c } e : 2;
|
||||
} x = {
|
||||
.e = 2,
|
||||
};
|
||||
TYPE_SIGNED(typeof(x.e));
|
||||
}));
|
||||
|
||||
ASSERT(4, sizeof(struct { int x : 1; }));
|
||||
ASSERT(8, sizeof(struct { long x : 1; }));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue