- Disable
-Wunused-function
with-std=c89/90
, since it would cause bogus warnings withmath.h
, because libc vendors use__inline
in standard headers. - Parse qualifiers and storage class after tag definition.
e.g.
Other compilers accept the third one, but they seem to be confused about it as well.
struct s0 { int x; } static; // OK, but deprecated since C23 struct s1 { int y; } const; // 'const' is ignored, emit warning struct s2 { int z; } const typedef s2; // Error
- Collapse
-Wattributes
and-Wignore-attributes
into one option. - Enable
-Wtautological-overlap-compare
with-Wall
. - More precise diagnostic message for mismatching argument count with variadic functions.
- Use SSE4.1 instructions for
_mm_set*
when-msse4.1
is set. - Disable
-gcolumn-info
by default, since gdb ignores it anyway. - Enable SSE version of
neg
IR instruction by default. - Mitigate UB on x64 for
__builtin_ctz(0)
, by encodingbsf
with therep
prefix. - Remove functions called only by unused functions (enabled by default).
-
Add universal charater names for strings and characters.
-
Add partial C23 support with the
-std=c23
switch:- Add keywords
alignas
,alingof
,static_assert
,thread_local
,typeof_unqual
,constexpr
. - Add
__has_c_attribute
. - Parse the new attribute syntax
[[]]
. - Predefine standard macros:
__STDC_UTF_16__
,__STDC_UTF_32__
. - Add digit separators.
- Add predefined constants:
true
,false
andnullptr
. foo()
becomes equivalent tofoo(void)
.- Add type inference with
auto
. Missing bit-fields initializers and traditional mode e.g.auto int x
will be (incorrectly) treated as an error. - Parse declarations after labels.
- Add standard attributes:
unsequenced
,reproducible
,nodiscard
,deprecated
,maybe_unused
,noreturn
,fallthrough
. - Add enum type specifier.
- Add keywords
-
Add
-Wextern-initializer
, enabled by default. -
Add
-Wimplicit-fallthrough
. -
Warn about assignments to read-only locations. e.g.
"foo"[x] = 'a';
. -
Add attribute
nodebug
. -
Add inline codegen for
__builtin_memset
also for non zero initialization values. -
Add debug-info for bitfields.
-
Add
__builtin_memcmp
with inline simd codegen, when the size is known at compile time. -
Add argument checking for intrinsics requiring a constant integer argument within a certain range.
-
Start riscv64 backend.
- Add
-march=rv64g
option. - Predefine macros:
__riscv
, ... to complete
- Add
-
arm64 backend
- Add codegen for
__builtin_bswap/ctz/clz/clrsb/parity/ffs/popcnt
. - Handle non-zero clear byte for
__builtin_memset
. - Encode bitmask (logical) immediates.
- Add codegen for
-
x64 backned:
- Add all AVX/AVX2 intrinsics, except for:
_mm_broadcastb_epi*
,_mm256_broadcastb_epi*
which use EVEX encoding. - Add BMI1, MOVBE,
_rdtscp
, RDRAND, RDSEED, RDPID intrinsics. - Predefine
__BMI__
,__BMI2__
,__MOVBE__
,__RDSEED__
,__RDPID__
,__RDRND__
,__AVX__
,__AVX2__
. - Add
-mbmi
,-mbmi2
,-mrdrnd
,-mrdseed
,-mrdpid
,-mmovbe
,-mavx
,-mavx2
command-line options.
- Add all AVX/AVX2 intrinsics, except for:
-
Build more stuff: 8080, BearSSL, libcox, luigi, mg, oed, parson, pl0c, qbe, utf8.h, vce, z80.
- Remove
-Wcast-function-type
.
- Fix segfault caused by recursive enum valuation in compile-time
__builtin_overflow_*
, caused bytypeof
. Now it's possible to write:#define __builtin_add_overflow_p(a,b) __builtin_add_overflow(a, b, (typeof((a) + (b))*)0) enum { A = 0x7FFFFFFF, B = 3, C = __builtin_add_overflow_p(A, B) ? 0 : A + B, };
- Fix incorrect
sizeof
parsing with un-parenthesized member expressions, like:sizeof ((struct foo *)0)->bar
. - Fix multi-byte escape sequences for UTF16/32 strings/characters.
- Fix undiagnosed
-Wdangling-else
. - Fix bug with
-Wtautological-overlap-compare
. - Fix debug-info issues
- Inspect
static
local variables. - Step on multi-line conditional expressions.
- Inspect anonymous enums.
- Inspect
- Fix bitfield related bugs.
- Fix a bug with
-Wpointer-to-int-cast
.
- Do not emit unused
static
functions by default. This reduces compile-time and if the user want to run a function in the debugger it can always mark it with theused
attribute. - Always reduce unsigned divides by a power of two.
- Rename
-march=host
into-march=native
for compatiblity with GCC. - Enable
-Wreturn-type
by default. - Temporarily disable
-Wsequence-point
, since it's giving false positive on real software. - Incorporate
-Woverlength-strings
into-Wpedantic
. - Merge
-m
and-march
into a single option. - Emit
movdqa
instead ofmovaps
for memory ops, when the vector subtype is an integer type. - Improve diagnostic for argument count mismatch errors. Use the first argument position having incompatible type when there is one, otherwise use the function call '(' position like before.
- Accept storage class after tag type specifiers in declarations/definitions.
- Disable
-Wmisleading-indentation
, since it sometimes gives false positives.
- Add attributes:
noinline
,always_inline
,hot
,cold
andnoipa
. - Parse attributes after pointer types. e.g.
void *__attribute__((noinline)) foo();
- Add warnings:
-Wstack-usage
,-Wcompare-distinct-pointer-types
,-Winline
,-Wunused-macros=main
,-Wunused-macros=nosys
,-Wunused-macros=all
,-Wenum-int-mismatch
,-Wtautological-overlap-compare
,-Winvalid-memory-model
,-Wundefined-internal
. - Add options:
-pthread
,-foptim-report
,-finline
,-msse3
,-mssse3
,-msse4
,-msse4.1
,-msse4.2
. - Add builtins:
__atomic_*
,__builtin_frame_address
,__builtin_return_address
,__builtin_stack_address
. - Implement
__builtin_unreachable
for-O1
and-O0
. - Add optimization passes:
- Register promotion.
- Dead code elimination.
- Constant propagation.
- Common sub-expression elimination.
- Strength reduction.
- Inlining.
- Dead argument elimination.
- Various form of CFG reductions.
- Omit frame prolog/epilog for leaf functions with -O1, when possible.
- Restore SWITCH reduction to range change.
- Add SEL reduction for power of 2.
e.g.
if (cond) flags |= The_Flag
=>flags |= (cond << bit(The_Flag))
- Build more open-source projects: chibicc, cproc, gc, gennan, quadsort, renderer, rpng, siod, sqlite3, tinn.
- Remove
-save-temps
. - Remove
-Wformat-security
. - Remove old debug-info code for recording type qualifiers.
Pros:
- they are not needed to actually debug an application,
- they make the executable bigger,
- implementation-wise they are akward,
- most people probably don't care. Cons:
- One might want to inspect debug-info for getting AST info, but again we provide better options for that.
- Remove
file_scope
attribute. Now it's a custom attribute.
- Fix warnings:
-Wignored-qualifiers
,-Wmissing-prototypes
,-Wreturn-local-addr
,-Wshift-negative-value
,-Wtype-limits
,-Wenum-conversion
,-Wtautological-compare
. - Fix linking bug caused by missing some CRT objects.
- Fix self-hosting regressions.
- Fix edge case bugs in initializers.
- Show function definition on calls with mismatch argument count.
-Wpedantic
with-std=c89
is best effort, it won't catch all later features uses. Most people have move on to later standards, so it doesn't make sense to add complexity for this.- Display helper message for invalid multi-dimensional arrays only once, since it's always the same.
- Change
__FUNCTION__
behavior like MSVC. - Compile as C11 by default.
- Change fatal exit code from 130 to 1.
- Make operator overloading ignore typedefs.
- Add spellchecking for undeclared members.
- Add
-Wunused-but-set-variable
. - Add basic support for inline assembly, just templates, outputs and clobbers.
- Add basic cross-compilation support for arm64.
- Add
-Wunused-result
andwarn_unused_result
attribute. - Add
-Wunused-parameter
. - Add warning for extern variables with initializer.
- Add UTF8/16 string and character literals.
- Add
#pragma pack
. - Add
#pragma message
. - Add
#pragma warning
. - Add
#pragma error
. - Add
#pragma dependency
. - Add
#elifdef/elifndef
. - Add
-Wunused-macros
. - Show macro expansion in error messages.
- Generate code for run-time
__builtin_offsetof
. - Spellcheck undeclared identifiers.
- Spellcheck invalid cpp directives.
- Do not support VLA, always treat them as errors.
- Remove
-Wmultichar
. Treat it as an error, since it is implementation defined. - Remove cast to union extension.
- Remove
-fsigned-char
. - Remove
-fauto-typedef
. Implement it as a plugin.
- Restore
-Wbad-function-cast
. - Properly treat
_Generic
expression as lvalue when the selected expression is indeed an lvalue. - Fix bugs related to lvalue-to-rvalue conversion.
-
Rename
-fzii
into-ftrivial-auto-var-init
to be compatible with GCC and add support for pattern initialization. -
Fuse load followed by arithmetic instruction. Enable this by default, since the compiler's performance didn't resent much.
-
Do not allow
extern void
variables. For some reason GCC and CLANG allow them, while MSVC doesn't. -
Set max array size to 4GB. MSVC limit is 2GB, CLANG limit is much bigger (thousand of TB) and GCC even larger (
__SIZE_MAX__/2
or something). In practice the max stack size is around 10-30MB and allocating arrays that big is unusual. Maybe we should add a flag (-fstack-limit maybe?) to allow huge arrays, since they might be used for debugging purposes. -
Disable
__label__
parsing. -
Do not allow unicode identifiers, since it adds complexity for an arguably useless feature (i.e. code is written in english).
It's also a source of security vulnerabilities.
- Add
-Wreturn-type
- Add
-Wconversion
- Emit debug info for SIMD types.
- Add
__builtin_unreachable
- Predefine conditional feature macros:
__STDC_NO_ATOMICS__
,__STDC_NO_COMPLEX__
,__STDC_NO_THREADS__
,__STDC_NO_VLA__
.
- Add consecutive immediate stores fusion optimization.
- Add
-x
option to select the language for input files. - Add
-fswitch-strategy
and__builtin_switch_strategy
for selecting the switch lowering method. - Add
__builtin_memset_strategy
and__builtin_memcpy_strategy
. - Plugin API for extending the compiler:
- AST inspection,
- Custom attributes and builtins,
- Callbacks
- Add
optimize
attribute. - Support consencutive label definitions in the assembler.
- Cleanup operator overloading attribute: more operands, symmetric property, better error checking.
- Encode
clflush
,clflushopt
,cldemote
,clrssbsy
,bt
,btc
,btr
andbts
. - Add signed integer overflow run-time checking with
-fcheck-signed-overflow
. - Improve code generation for
_mm_set_*
intrinsics with homogeneous arguments, using SSE3/SSSE3 intrinsics when available. __builtin_memset/memcpy
are now considered intrinsics.- Add
__builtin_trap
. - Add overflow builtins. Do not add the _p variants since they are redundant.
- Add uninitialized attribute for
-fzii
. - Add
-Wvarargs
. - Allow the user to specify built-in functions through
-fplugin
. - Read string literals and character constants in utf8 and convert them in the requested encoding. Wide string literals and character constants are encoded in utf32.
- Remove the additional helper message for unterminated condition, since it cause more confusion.
- Remove RTTI. The major drawback is additional work in the compiler, plus you can't debug the generated code. In contrast the same feature could be implemented through a meta-programming preprocessing pass using the pluing API.
- Remove
-Wlong-long
, since it's also enabled by-Wpedantic
and nobody care aboutlong long
anyway.
- Fix
-Wsign-compare
- Fix
-Waddress
- Restore
-Wnonnull
,-Wnonnull-compare
,-Wunused-function
,-Wunused-label
,-Wunused-variable
,-Wsizeof-pointer-memaccess
. - Restore
__builtin_nan
- Restore
__builtin_cpu_supports
. - Restore
-Woverflow
,-Wbool-operation
,-Wchar-subscripts
,-Wint-in-bool-context
,-Wcomment
,-Wdouble-promotion
,-Wtautological-compare
,-Wsizeof-array-argument
. - Restore type inference with
__auto_type
or withauto
in C23.
- Internal assembler for x86_64
- Bit-fields.
- Thread-local storage.
- Fix x87 register allocation.