|
| 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) |
0 commit comments