Skip to content

Commit b6dd21c

Browse files
committed
Describe C99 compliance
shecc implements a subset of C99 suitable for self-hosting and system programming, prioritizing simplicity, educational value, and minimal dependencies over full standard compliance.
1 parent d7dd5d2 commit b6dd21c

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed

COMPLIANCE.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# C99 Compliance Status
2+
3+
shecc implements a subset of C99 suitable for self-hosting and systems programming,
4+
prioritizing simplicity, educational value, and minimal dependencies over full standard compliance.
5+
This document tracks compliance gaps and non-standard behaviors.
6+
7+
## Implemented Features
8+
9+
### Core Language
10+
- Basic types: `int`, `char`, `void`, `_Bool`
11+
- Structures and unions with nested definitions
12+
- Enumerations with automatic value assignment
13+
- Function definitions and declarations
14+
- Arrays (single and multi-dimensional)
15+
- Pointers and pointer arithmetic (fully C99-compliant)
16+
- Type definitions (`typedef`)
17+
18+
### Control Flow
19+
- `if`/`else` statements
20+
- `while`, `do-while`, `for` loops
21+
- `switch`/`case`/`default` statements
22+
- `break`, `continue`, `return` statements
23+
24+
### Operators
25+
- Arithmetic: `+`, `-`, `*`, `/`, `%`
26+
- Bitwise: `&`, `|`, `^`, `~`, `<<`, `>>`
27+
- Logical: `&&`, `||`, `!`
28+
- Relational: `<`, `>`, `<=`, `>=`, `==`, `!=`
29+
- Assignment: `=`, `+=`, `-=`, `*=`, `/=`, `%=`, `<<=`, `>>=`, `&=`, `|=`, `^=`
30+
- Increment/decrement: `++`, `--` (prefix and postfix)
31+
- Conditional: `? :`
32+
- Member access: `.`, `->`
33+
- Address/dereference: `&`, `*`
34+
35+
### Preprocessor (Partial)
36+
- `#define` for object-like and function-like macros
37+
- `#ifdef`, `#ifndef`, `#if`, `#elif`, `#else`, `#endif`
38+
- `#undef` for macro removal
39+
- `defined()` operator
40+
- `__VA_ARGS__` for variadic macros
41+
42+
## Missing Features
43+
44+
### Storage Classes & Qualifiers
45+
46+
| Feature | Status | Impact |
47+
|---------|--------|--------|
48+
| `static` | Not implemented | No internal linkage or persistent local variables |
49+
| `extern` | Not implemented | No external linkage declarations |
50+
| `register` | Not implemented | No register hint optimization |
51+
| `auto` | Not implemented | Default storage class (implicit) |
52+
| `const` | Parsed but ignored | No read-only enforcement |
53+
| `volatile` | Not implemented | No volatile semantics |
54+
| `restrict` | Not implemented | No pointer aliasing optimization |
55+
| `inline` | Not implemented | No function inlining |
56+
57+
### Type System
58+
59+
| Feature | Status | Notes |
60+
|---------|--------|-------|
61+
| `short` | Missing | Only 4-byte integers |
62+
| `long` | Missing | Only 4-byte integers |
63+
| `long long` | Missing | No 64-bit integers |
64+
| `unsigned` | Missing | All integers are signed |
65+
| `signed` | Missing | Implicit for integers |
66+
| `float` | Missing | No floating-point support |
67+
| `double` | Missing | No floating-point support |
68+
| `long double` | Missing | No floating-point support |
69+
| Bit-fields | Missing | Cannot pack struct members |
70+
71+
### Literals & Constants
72+
73+
| Feature | Status | Current Behavior |
74+
|---------|--------|-----------------|
75+
| Integer suffixes (`u`, `l`, `ll`) | Not parsed | All literals are `int` |
76+
| Wide characters (`L'c'`) | Not supported | Single-byte only |
77+
| Wide strings (`L"..."`) | Not supported | Single-byte only |
78+
| Multi-character constants | Not supported | Single character only |
79+
| Universal characters (`\u`, `\U`) | Not supported | ASCII only |
80+
| Hex escapes (`\x...`) | Limited | Max 2 hex digits |
81+
82+
### Preprocessor Gaps
83+
84+
| Feature | Status | Description |
85+
|---------|--------|-------------|
86+
| `#include` | Parsed only | No file inclusion |
87+
| Token pasting (`##`) | Missing | Cannot concatenate tokens |
88+
| Stringizing (`#`) | Missing | Cannot convert to string |
89+
| `__FILE__` | Missing | No file name macro |
90+
| `__LINE__` | Missing | No line number macro |
91+
| `__DATE__` | Missing | No compile date |
92+
| `__TIME__` | Missing | No compile time |
93+
| `__STDC__` | Missing | No standard compliance indicator |
94+
| `#pragma` | Ignored | Accepted but no effect |
95+
96+
### Advanced Features
97+
98+
| Feature | Status | Description |
99+
|---------|--------|-------------|
100+
| `goto` and labels | Missing | No arbitrary jumps |
101+
| Designated initializers | Missing | No `.field = value` syntax |
102+
| Compound literals | Partial | Limited support |
103+
| Flexible array members | Missing | No `[]` at struct end |
104+
| Variable-length arrays | Missing | No runtime-sized arrays |
105+
| `_Complex` | Missing | No complex numbers |
106+
| `_Imaginary` | Missing | No imaginary numbers |
107+
| `_Static_assert` | Missing | No compile-time assertions |
108+
| `_Alignof` | Missing | No alignment queries |
109+
| `_Alignas` | Missing | No alignment specification |
110+
| `_Generic` | Missing | No generic selection |
111+
112+
## Non-Standard Behaviors
113+
114+
### GNU Extensions
115+
- Binary literals: `0b101010`
116+
- Escape sequence: `\e` for ESC character
117+
- `void*` arithmetic (treated as `char*`)
118+
- `sizeof(void)` returns 0 (should be error)
119+
120+
### Implementation-Specific
121+
- Array compound literals in scalar context use first element
122+
- String literals are modifiable (stored in `.data`, not `.rodata`)
123+
- No strict aliasing rules
124+
- Left-to-right evaluation order (not always guaranteed in C99)

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ we might request an issue to be filed to facilitate discussion on broader design
3131

3232
Visit our [Issues page on GitHub](https://github.com/sysprog21/shecc/issues) to search and submit.
3333

34+
## Language Compliance
35+
36+
Before contributing new language features or modifications to the compiler frontend,
37+
please review [COMPLIANCE.md](COMPLIANCE.md) to understand shecc's current C99 compliance status,
38+
supported features, and known limitations. This document helps ensure that contributions
39+
align with the project's subset implementation philosophy.
40+
3441
## Coding Convention
3542

3643
Contributions from developers across corporations, academia, and individuals are welcome.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ int fib(int n) def int @fib(int %n)
235235
} }
236236
```
237237
238+
## C99 Compliance
239+
240+
shecc implements a subset of C99 suitable for self-hosting and systems programming.
241+
For detailed information about supported features, missing functionality, and non-standard behaviors,
242+
see [COMPLIANCE.md](COMPLIANCE.md).
243+
238244
## Known Issues
239245
240246
2. Full `<stdarg.h>` support is not available. Variadic functions work via direct pointer arithmetic.

0 commit comments

Comments
 (0)