Rui Ueyama
7d80a5136d
Add typeof
2020-12-07 12:00:06 +09:00
Rui Ueyama
007e526ec5
[GNU] Support GCC-style variadic macro
2020-12-07 12:00:06 +09:00
Rui Ueyama
74ec9f6f39
Ignore #pragma
2020-12-07 12:00:06 +09:00
Rui Ueyama
083c27559e
[GNU] Handle ,##__VA_ARG__
2020-12-07 12:00:06 +09:00
Rui Ueyama
338144869f
Add __VA_OPT__
2020-12-07 12:00:06 +09:00
Rui Ueyama
3a10c8aa44
[GNU] Add __BASE_FILE__ macro
2020-12-07 12:00:06 +09:00
Rui Ueyama
922604ae1e
[GNU] Add __TIMESTAMP__ macro
2020-12-07 12:00:06 +09:00
Rui Ueyama
aaf20fb96e
[GNU] Add line marker directive
2020-12-07 12:00:06 +09:00
Rui Ueyama
c61c0d0025
Add #line
2020-12-07 12:00:06 +09:00
Rui Ueyama
37998be0c1
Improve error message for multibyte characters
2020-12-07 12:00:06 +09:00
Rui Ueyama
95eb5b01b3
Handle struct designator for anonymous struct member
2020-12-07 12:00:06 +09:00
Rui Ueyama
31dc1dfa21
Add union designated initializer
2020-12-07 12:00:06 +09:00
Rui Ueyama
67f5834378
Add struct designated initializer
2020-12-07 12:00:06 +09:00
Rui Ueyama
691c4fac15
[GNU] Allow to omit "=" in designated initializers
2020-12-07 12:00:06 +09:00
Rui Ueyama
835cd24b2c
Allow array designators to initialize incomplete arrays
2020-12-07 12:00:06 +09:00
Rui Ueyama
c618c3b582
Add array designated initializer
2020-12-07 12:00:06 +09:00
Rui Ueyama
2b2fa25507
Skip UTF-8 BOM markers
2020-12-07 12:00:06 +09:00
Rui Ueyama
238277714d
Allow to concatenate regular string literals with L/u/U string literals
2020-12-07 12:00:06 +09:00
Rui Ueyama
adb8b98889
[GNU] Accept $ as an identifier character
2020-12-07 12:00:06 +09:00
Rui Ueyama
0e5d250ebf
Allow multibyte UTF-8 character in identifier
2020-12-07 12:00:06 +09:00
Rui Ueyama
e4491b8115
Define __STDC_UTF_{16,32}__ macros
...
These predefined macros indicates that our u and U chars/strings
are UTF-16 and UTF-32-encoded, respectively.
2020-12-07 12:00:06 +09:00
Rui Ueyama
6adba75af8
Add UTF-32 string literal initializer
2020-12-07 12:00:06 +09:00
Rui Ueyama
36230e0827
Add UTF-16 string literal initializer
2020-12-07 12:00:06 +09:00
Rui Ueyama
cae061af2b
Add wide string literal
2020-12-07 12:00:06 +09:00
Rui Ueyama
c467ee665d
Add UTF-32 string literal
2020-12-07 12:00:06 +09:00
Rui Ueyama
9cabe1f204
Add UTF-16 string literal
2020-12-07 12:00:06 +09:00
Rui Ueyama
57b21fe902
Add UTF-8 string literal
2020-12-07 12:00:06 +09:00
Rui Ueyama
2dac3afece
Add UTF-32 character literal
2020-12-07 12:00:06 +09:00
Rui Ueyama
454618cd15
Add UTF-16 character literal
2020-12-07 12:00:06 +09:00
Rui Ueyama
a57c661d46
Accept multibyte character as wide character literal
...
On most Unix-like systems, wide character literal is 32-bit long
and encodes a Unicode code point. On Windows, that is 16-bit
long and encodes a UTF-16 code unit. Clearly, there's a portability
issue here. Personally I've never used wide characters in my code
as I didn't find it useful.
Being said that, some header files contain wide character literal,
so we need to support that so that chibicc can include such files.
We assume that source files are always encoded in UTF-8.
2020-12-07 12:00:06 +09:00
Rui Ueyama
c31886aa7a
Add \u and \U escape sequences
2020-12-07 12:00:06 +09:00
Rui Ueyama
74bcec5b22
Canonicalize newline character
2020-12-07 12:00:06 +09:00
Rui Ueyama
0e77f3dff8
[GNU] Add __COUNTER__ macro
2020-12-07 12:00:06 +09:00
Rui Ueyama
e27417fcde
Add __DATE__ and __TIME__ macros
2020-12-07 12:00:06 +09:00
Rui Ueyama
c3075b3030
Add anonymous struct and union
2020-12-07 12:00:06 +09:00
Rui Ueyama
9c36dd727c
Make "main" to implicitly return 0
2020-12-07 12:00:06 +09:00
Rui Ueyama
5257ee0f20
Make an array of at least 16 bytes long to have alignment of at least 16 bytes
...
Quote from AMD64 System V ABI: "An array uses the same alignment as
its elements, except that a local or global array variable of length
at least 16 bytes or a C99 variable-length array variable always has
alignment of at least 16 bytes."
2020-12-07 12:00:06 +09:00
Rui Ueyama
2c91da54df
Turn on -Wall compiler flag and fix compiler warnings
2020-12-07 12:00:06 +09:00
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