aboutsummaryrefslogtreecommitdiffhomepage
path: root/c
Commit message (Collapse)AuthorAgeFilesLines
* some static assertions for packed type sizeslemon2025-12-201-6/+8
|
* backend: unify pass memory allocation strategieslemon2025-12-201-1/+1
| | | | | | It was all over the place for temporary data structures used by individual passes. Now there is an arena specifically for that, which is nicer.
* c: support CRLF newlineslemon2025-12-201-3/+11
|
* c: fix a silly C edge case with function redeclaration storage classlemon2025-12-201-14/+21
| | | | | | C (or at least clang and gcc) allows declaring `static int f(...);` and defining it later as `int f(...) {...}`, omitting the 'static' in the latter definition.
* lexer: fix remnant use of TKEOF for characterlemon2025-12-201-9/+7
|
* optimize lexer a bit morelemon2025-12-202-62/+88
|
* lexer: convert pp-idents to keywords only after preprocessinglemon2025-12-202-71/+75
|
* c: factor out to tldecl(), improve error recovery,lemon2025-12-201-73/+97
|
* c.h init zero bitset portabilitylemon2025-12-191-1/+1
|
* c: support 0-length arrays as syntax for flexible array memberslemon2025-12-191-19/+29
| | | | | Keeping the expr around in the decllist paves the way for VLA support later on
* c: fix incr/decr codegen for floatslemon2025-12-191-2/+2
|
* c: hack to support __FUNCTION__ GNU extensionlemon2025-12-191-4/+10
|
* cpp: GNU extension for named variadic argumentslemon2025-12-181-4/+7
|
* cpp: better error recovery for #define syntax errorlemon2025-12-181-6/+7
|
* c: fix uninitiliazed field in decltypeslemon2025-12-171-0/+1
|
* nicer defaults and facilities for cross-compilationlemon2025-12-171-2/+16
|
* c: improve some type error diagnosticslemon2025-12-151-13/+22
|
* create distinct interned string typelemon2025-12-154-75/+76
| | | | | | | | | | | | | | Interned strings are used pervasively, so it's a good idea to add a layer of type safety to differentiate them from general cstrs and avoid potential bugs from comparing non-interned and interned strings. Not that that's happened so far that I can remember, but it could. I'm 90% sure it's legal to alias `struct {char c;}` pointers with `char` pointers. This specific typedef gives type safety but with a simple one-way `internstr -> const char *` typecast (with `&istr->c`). Converting the other way around is more intentional: a straight up cast `(internstr)cstr` which sticks out as unchecked and probably wrong, or calling the intern(cstr) function, which is the right way.
* move intern() to mem.clemon2025-12-153-47/+0
| | | | | Being in lex.c was vestigial, since it was being used all over the frontend and backend.
* lex: loop with goto instead of tail recursionlemon2025-12-151-7/+8
| | | | | This uncovered a edgecase with loops and lifetime construction in regalloc!
* lexer: use a hashmap to lookup keywordslemon2025-12-152-28/+28
|
* c: error when defining function with incomplete parameter typelemon2025-12-151-0/+4
|
* c: support forward-declared enumslemon2025-12-151-34/+32
| | | | This is a common non-standard GNU extension.
* c: emit data for __func__ lazilylemon2025-12-151-15/+16
|
* c: fix another memory-leak-when-errors caselemon2025-12-141-1/+2
|
* c: as a hack, warn for zero-length array instead of errorlemon2025-12-141-1/+1
| | | | | Treated as unsized array T[]. This shows up in some linux headers as a non-standard way to have flexible array members.
* c/builtin: fix vacopylemon2025-12-141-5/+6
|
* c: fix memory leak if initializer data if errorlemon2025-12-141-1/+1
|
* eval: long double placeholderlemon2025-12-141-1/+2
|
* cpp: support #line directiveslemon2025-12-141-10/+75
|
* cpp: correctly handle extra tokens after directiveslemon2025-12-141-16/+21
|
* only put dats can in .text now when emitting itlemon2025-12-141-2/+2
|
* various relocation related optimizationlemon2025-12-141-3/+3
| | | | | | | | | | With 59ca5a8db, querying if a symbol is defined is cheap. If we're compiling code that calls foo() and we defined foo() in this compilation unit, we already know its offset within the .text section, so use it instead of emitting a relocation for the linker to handle. Also, put small literal data in the .text section instead of .rodata. This seems to improve performance (cache locality?), and as a bonus, it will be good for aarch64's instr encoding with smallish PC-relative offsets.
* c: handle more static eval edgecases for int -> ptrlemon2025-12-132-5/+20
| | | | | sqlite3 was falling back to `((void*)&((char*)0)[X])` for INT_TO_PTR, which this handles now.
* c: case/default labels only create new blocks when necessarylemon2025-12-131-7/+11
|
* fix position independent loads of function symbols.lemon2025-12-131-3/+3
| | | | | | | | For `extern int x[1];`, can use PCREL32 for &x. But for `extern int x(int)`, must use GOTREL, when not being called directly (that's PLT). Therefore the type of an external symbol (actually just whether it denotes a function) matters when deciding what kind of relocation to emit, so keep that information.
* s/amd64/x86_64/lemon2025-12-121-1/+1
|
* c: switch stmt diagnosticslemon2025-12-121-8/+49
| | | | For duplicate cases, case value overflow
* lex: use pmap for macro lookuplemon2025-12-122-126/+70
| | | | To reduce hashmap code repetition. Also add pmap_del for this purpose
* rename arraylength macro -> countoflemon2025-12-113-51/+51
|
* c: accept C99 `[static N]` style array decls, changes to fn qualslemon2025-12-111-24/+45
| | | | | | Function parameters qualifiers don't matter outside of function definition. `int (const int)` should be compatible with `int(int)` etc. So no need to store them in the typedata.
* _Alignof and stufflemon2025-12-111-11/+18
|
* c: use a look-up table for isdecltok()lemon2025-12-111-14/+18
|
* -trigraphs optionlemon2025-12-111-3/+3
|
* c: optimize environment decl lookuplemon2025-12-111-6/+26
| | | | | Use a hashmap for the toplevel, optimizing for the common use case where the file-scope has many more declarations than local scopes do
* c: disallow mismatched nested extern decl, & more diagnosticslemon2025-12-111-17/+24
|
* c: support for noreturn, and decl parsing cleanuplemon2025-12-112-107/+115
|
* lex/expr(): cleanuplemon2025-12-111-29/+29
|
* c: expr2reloc() change sig to return addendlemon2025-12-111-15/+12
|
* lexer: properly add padding for cpppredefslemon2025-12-101-2/+2
|