mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Enhance chibicc
This commit is contained in:
parent
8da931a7f6
commit
9df2cef4c4
52 changed files with 2606 additions and 2004 deletions
42
third_party/chibicc/test/dce_test.c
vendored
Normal file
42
third_party/chibicc/test/dce_test.c
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include "third_party/chibicc/test/test.h"
|
||||
|
||||
int x;
|
||||
|
||||
int main(void) {
|
||||
if (0) {
|
||||
asm(".error \"the assembler shall fail\"");
|
||||
}
|
||||
|
||||
x = 1 ? 777 : ({
|
||||
asm(".error \"the system is down\"");
|
||||
666;
|
||||
});
|
||||
ASSERT(777, x);
|
||||
|
||||
x = 0;
|
||||
x = 777 ?: ({
|
||||
asm(".error \"the system is down\"");
|
||||
666;
|
||||
});
|
||||
|
||||
x = 0;
|
||||
x = __builtin_popcount(strlen("hihi")) == 1 ? 777 : ({
|
||||
asm(".error \"the system is down\"");
|
||||
666;
|
||||
});
|
||||
ASSERT(777, x);
|
||||
|
||||
x = 0;
|
||||
x = strpbrk("hihi", "ei") ? 777 : ({
|
||||
asm(".error \"the system is down!\"");
|
||||
666;
|
||||
});
|
||||
ASSERT(777, x);
|
||||
|
||||
x = 0;
|
||||
x = !__builtin_strpbrk("HELLO\n", "bxdinupo") ? 777 : ({
|
||||
asm(".error \"the system is down\"");
|
||||
666;
|
||||
});
|
||||
ASSERT(777, x);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue