Commit b614f35
committed
Harden frontend for v0.2.0 release
* Fixed segfault issue with arena allocator, beefed up test harness to tell if the rror cases errored correctly
* Fixed holes in analyzer type checking system, Added special error type for analyzing program with no main
* Reformatted LOC summary to split test harness code from compiler code
* Fixed bug with string escape truncation in the tokenizer, made struct decls consistent with semi colons
* Fix lexer error recovery and add struct-typed global parsing
Lexer: consume entire malformed number literal before returning an
error so diagnostics aren't repeated per digit. Add ERANGE check
for strtol overflow.
Parser: accept struct-typed globals at file scope (identifier
lookahead, same pattern as local declarations). Allow optional
trailing semicolon after struct closing brace. Add NULL check
after malloc in GENERATE_ERROR macro.
AST printer: loop ptr_depth for correct star count (u16** not u16*),
add depth guard in print_ast_labeled.
* Add error kinds for analyzer hardening
New error types: ERR_MISSING_MAIN, ERR_LITERAL_OUT_OF_RANGE,
ERR_NOT_LVALUE, ERR_VOID_VARIABLE, ERR_NOT_A_STRUCT,
ERR_MISSING_RETURN. Add lvalue union member to error_t.
Fix type_to_string to loop ptr_depth with a local stars buffer
instead of printing a single star.
* Close silent-accept gaps in semantic analyzer
Validate declared types everywhere (locals, params, globals, regs,
fields, return types) - unknown structs and non-pointer void rejected
at the declaration site. Bad symbols poisoned with TYPE_INVALID to
prevent cascading diagnostics.
New checks: lvalue validation for assignment/&/++/--, integer literal
range checking, negative literal typing (-5 as i8 not u8), global
initializer type checking, bare return in non-void rejection, shallow
missing-return detection, struct pointer auto-deref for field access.
* Update README and CHANGELOG for v0.2.01 parent b00e811 commit b614f35
54 files changed
Lines changed: 1023 additions & 145 deletions
File tree
- cc02
- src
- analysis
- common
- lexer
- parser
- tests
- golden
- smoke
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
39 | 68 | | |
40 | 69 | | |
41 | 70 | | |
| |||
54 | 83 | | |
55 | 84 | | |
56 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
57 | 98 | | |
58 | 99 | | |
59 | 100 | | |
| |||
96 | 137 | | |
97 | 138 | | |
98 | 139 | | |
99 | | - | |
100 | 140 | | |
101 | 141 | | |
102 | 142 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
89 | | - | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
139 | | - | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| 145 | + | |
143 | 146 | | |
144 | 147 | | |
145 | 148 | | |
146 | 149 | | |
147 | 150 | | |
148 | 151 | | |
| 152 | + | |
149 | 153 | | |
150 | 154 | | |
151 | 155 | | |
| 156 | + | |
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
| |||
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
206 | | - | |
| 211 | + | |
207 | 212 | | |
208 | 213 | | |
209 | 214 | | |
| |||
0 commit comments