Commit Graph

316 Commits

Author SHA1 Message Date
Rui Ueyama b1fdddff15 Ignore -O, -W and -g and other flags 2020-12-07 12:00:06 +09:00
Rui Ueyama 2bdc6b800c Write to an in-memory buffer before writing to an actual output file
We don't want to leave a partial assembly output if the compiler
fails during compilation.

Technically speaking, there's still a risk of leaving a partially-
written output file if the compiler dies during file copy. To fix
that, we have to write to a temporary file in the same filesystem as
the final output file and rename the temporary file to atomically
replace the output file. We don't do that in this patch for the sake
of succinctness, though.
2020-12-07 12:00:06 +09:00
Rui Ueyama c302a969d8 Do not allow to obtain an address of a bitfield 2020-12-07 12:00:06 +09:00
Rui Ueyama 17ea802cea Handle zero-width bitfield member 2020-12-07 12:00:06 +09:00
Rui Ueyama 54c2b3b18f Handle op=-style assignments to bitfields 2020-12-07 12:00:06 +09:00
Rui Ueyama 441a89b80b Support global struct bitfield initializer 2020-12-07 12:00:06 +09:00
Rui Ueyama cc852fe99d Add bitfield 2020-12-07 12:00:06 +09:00
Rui Ueyama be8b6f6d31 Add -U option 2020-12-07 12:00:06 +09:00
Rui Ueyama fc69f5c6f9 Add -D option 2020-12-07 12:00:06 +09:00
Rui Ueyama 3f2c2d5bca Tokenize numeric tokens as pp-numbers 2020-12-07 12:00:06 +09:00
Rui Ueyama e0b5da3b39 Dereferencing a function shouldn't do anything
This is an oddity in the C spec, but you can apply the unary `*`
operator to a function as many times as you want. `*x` and `x`
means exactly the same, given that `x` is a function.
2020-12-07 12:00:06 +09:00
Rui Ueyama 603de502fd Add va_copy() 2020-12-07 12:00:06 +09:00
Rui Ueyama b6d3cd00df Allow variadic function to take more than 6 parameters 2020-12-07 12:00:06 +09:00
Rui Ueyama d7bad96114 Allow to define a function returning a struct 2020-12-07 12:00:06 +09:00
Rui Ueyama c72df1c9be Allow to call a fucntion returning a struct 2020-12-07 12:00:06 +09:00
Rui Ueyama d63b1f410a Allow struct argument 2020-12-07 12:00:06 +09:00
Rui Ueyama 5e0f8c47e3 Allow struct parameter 2020-12-07 12:00:06 +09:00
Rui Ueyama 9021f7f5de Support passed-on-stack parameters 2020-12-07 12:00:06 +09:00
Rui Ueyama b29f052102 Support passed-on-stack arguments 2020-12-07 12:00:06 +09:00
Rui Ueyama 12a9e7506c Self-host: including preprocessor, chibicc can compile itself 2020-12-07 12:00:06 +09:00
Rui Ueyama 5322ea8495 Add va_arg() 2020-12-07 12:00:06 +09:00
Rui Ueyama 7cbfd111d3 Add stdarg.h, stdbool.h, stddef.h, stdalign.h and float.h 2020-12-07 12:00:06 +09:00
Rui Ueyama 7746e4ee0b Recognize wide character literal
For now, L'' is equivalent to ''.
2020-12-07 12:00:06 +09:00
Rui Ueyama ab4f1e1e19 Concatenate adjacent string literals 2020-12-07 12:00:06 +09:00
Rui Ueyama 82ba010c76 [GNU] Add __FUNCTION__ 2020-12-07 12:00:06 +09:00
Rui Ueyama ba6b4b6375 Add __func__ 2020-12-07 12:00:06 +09:00
Rui Ueyama dc01f94900 Add __VA_ARGS__ 2020-12-07 12:00:06 +09:00
Rui Ueyama 6f17071885 Add __FILE__ and __LINE__ 2020-12-07 12:00:06 +09:00
Rui Ueyama 5f5a8507ff Add predefine macros such as __STDC__ 2020-12-07 12:00:06 +09:00
Rui Ueyama e7fdc2e3f1 Add #error 2020-12-07 12:00:06 +09:00
Rui Ueyama a939a7a906 Add default include paths 2020-12-07 12:00:06 +09:00
Rui Ueyama a1dd6213c8 Add -I<dir> option 2020-12-07 12:00:06 +09:00
Rui Ueyama d85fc4ffcf Add #include <...> 2020-12-07 12:00:06 +09:00
Rui Ueyama b33fe0ea82 Support line continuation 2020-12-07 12:00:06 +09:00
Rui Ueyama 8075582c21 Preserve newline and space during macro expansion 2020-12-07 12:00:06 +09:00
Rui Ueyama a8d76ad435 Replace remaining identifiers with 0 in macro constexpr 2020-12-07 12:00:06 +09:00
Rui Ueyama 5cb2f89e6a Add defined() macro operator 2020-12-07 12:00:06 +09:00
Rui Ueyama 769b5a0941 Use chibicc's preprocessor for all tests 2020-12-07 12:00:06 +09:00
Rui Ueyama 8f561aed9b Add macro token-pasting operator (##) 2020-12-07 12:00:06 +09:00
Rui Ueyama 8f6f7925a0 Add macro stringizing operator (#) 2020-12-07 12:00:06 +09:00
Rui Ueyama 1313fc6d3a Do not expand a token more than once for the same funclike macro 2020-12-07 12:00:06 +09:00
Rui Ueyama c7d7ce0f0c Allow parenthesized expressions as macro arguments 2020-12-07 12:00:06 +09:00
Rui Ueyama dd4306cdd8 Allow empty macro arguments 2020-12-07 12:00:06 +09:00
Rui Ueyama b9ad3e43cf Add multi-arity funclike #define 2020-12-07 12:00:06 +09:00
Rui Ueyama dec3b3fa02 Add zero-arity funclike #define 2020-12-07 12:00:06 +09:00
Rui Ueyama 1f80f581e5 Add #ifdef and #ifndef 2020-12-07 12:00:06 +09:00
Rui Ueyama acce00228b Do not expand a token more than once for the same objlike macro 2020-12-07 12:00:06 +09:00
Rui Ueyama 2651448084 Expand macros in the #if and #elif argument context 2020-12-07 12:00:06 +09:00
Rui Ueyama 9ad60e41d5 Add #undef 2020-12-07 12:00:06 +09:00
Rui Ueyama 97d33ad3bd Add objlike #define 2020-12-07 12:00:06 +09:00