Skip to content

Commit 748ffc9

Browse files
committed
Update README with accurate feature documentation
- Expand compatibility section with complete feature list including enum, typedef, do-while, continue, and all compound assignment operators - Document support for array initializers and multi-dimensional arrays - Clarify variadic function support (pointer arithmetic, not full stdarg.h) - Add typedef pointer support and multi-level pointer dereference - Document comprehensive preprocessor directive support
1 parent a235e67 commit 748ffc9

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ Despite its simplistic nature, it is capable of performing basic optimization st
2323

2424
`shecc` is capable of compiling C source files written in the following
2525
syntax:
26-
* data types: char, int, struct, and pointer
27-
* condition statements: if, while, for, switch, case, break, return, and
26+
* data types: `char`, `int`, `struct`, `enum`, `typedef`, and pointer types
27+
* condition statements: `if`, `else`, `while`, `for`, `do-while`, `switch`, `case`, `default`, `break`, `continue`, `return`, and
2828
general expressions
29-
* compound assignments: `+=`, `-=`, `*=`
30-
* global/local variable initializations for supported data types
31-
- e.g. `int i = [expr]`
32-
* limited support for preprocessor directives: `#define`, `#ifdef`, `#elif`, `#endif`, `#undef`, and `#error`
33-
* non-nested variadic macros with `__VA_ARGS__` identifier
29+
* operators: all arithmetic, logical, bitwise, and assignment operators including compound assignments
30+
(`+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `|=`, `^=`, `<<=`, `>>=`)
31+
* arrays: global/local arrays with initializers, multi-dimensional arrays
32+
* functions: function declarations, definitions, and calls with fixed arguments
33+
* variadic functions: basic support via direct pointer arithmetic (no `<stdarg.h>`)
34+
* typedef: type aliasing including typedef pointers (`typedef int *ptr_t;`)
35+
* pointers: full pointer arithmetic, multi-level pointer dereference (`***ptr`)
36+
* global/local variable initializations for all supported data types
37+
- e.g. `int i = [expr];`, `int arr[] = {1, 2, 3};`
38+
* preprocessor directives: `#define`, `#ifdef`, `#ifndef`, `#elif`, `#else`, `#endif`, `#undef`, `#error`, and `#include`
39+
* function-like macros with parameters and `__VA_ARGS__` support
3440

3541
The backend targets armv7hf with Linux ABI, verified on Raspberry Pi 3,
3642
and also supports RISC-V 32-bit architecture, verified with QEMU.
@@ -89,6 +95,12 @@ Run `make` and you should see this:
8995
SHECC out/shecc-stage2.elf
9096
```
9197

98+
For development builds with memory safety checks:
99+
```shell
100+
$ make sanitizer
101+
$ make check-sanitizer
102+
```
103+
92104
File `out/shecc` is the first stage compiler. Its usage:
93105
```shell
94106
$ shecc [-o output] [+m] [--no-libc] [--dump-ir] <infile.c>
@@ -128,11 +140,23 @@ use `update-snapshot` / `check-snapshot` instead.
128140

129141
### Unit Tests
130142

131-
`shecc` comes with unit tests. To run the tests, give `check` as an argument:
143+
`shecc` comes with a comprehensive test suite (200+ test cases). To run the tests:
132144
```shell
133-
$ make check
145+
$ make check # Run all tests (stage 0 and stage 2)
146+
$ make check-stage0 # Test stage 0 compiler only
147+
$ make check-stage2 # Test stage 2 compiler only
148+
$ make check-sanitizer # Test with AddressSanitizer and UBSan
134149
```
135150

151+
The test suite covers:
152+
* Basic data types and operators
153+
* Control flow statements
154+
* Arrays and pointers (including multi-level dereference)
155+
* Structs, enums, and typedefs
156+
* Variadic functions
157+
* Preprocessor directives and macros
158+
* Self-hosting validation
159+
136160
Reference output:
137161
```
138162
TEST STAGE 0
@@ -213,10 +237,11 @@ int fib(int n) def int @fib(int %n)
213237
214238
## Known Issues
215239
216-
1. The generated ELF lacks of .bss and .rodata section
217-
2. The support of varying number of function arguments is incomplete. No `<stdarg.h>` can be used.
218-
Alternatively, check the implementation `printf` in source `lib/c.c` for `var_arg`.
219-
3. The C front-end is a bit dirty because there is no effective AST.
240+
1. The generated ELF lacks .bss and .rodata sections
241+
2. Full `<stdarg.h>` support is not available. Variadic functions work via direct pointer arithmetic.
242+
See the `printf` implementation in `lib/c.c` for the supported approach.
243+
3. The C front-end operates directly on token streams without building a full AST.
244+
4. Complex pointer arithmetic expressions like `*(p + offset)` have limited support.
220245
221246
## License
222247

0 commit comments

Comments
 (0)