~sircmpwn/harec

Generate arbitrary names for @init functions

This reverts commit c9ef70be16800077288498ef8c61bbb3d14faa28, which
generated meaningful names, but the names ended up being quite long and
causing regressions by bumping into the maximum symbol name limit for
qbe.
Allow optional parameters in variadic functions.

Signed-off-by: Joe Finney <me@spxtr.net>
tests.mk: add missing testmod.td dependency
check: simplify switch exhaustivity checking

struct located_case isn't necessary, since the location is already
stored within the checked expression.

casecmp doesn't need to be updated, since it already casts the pointers
to `const struct expression **` and doesn't use the location.
Generate meaningful names for @init functions

Useful in case they show up in stack traces, disassemblies, etc.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
check: fix outdated comment about flexible promotion

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
check: rewrite check_expr_call

Make variadicity of the last argument a property of the call, not of the
last argument itself. Handle too many/not enough arguments in a more
obvious way. Simplify lowering of empty varargs in case of Hare
variadism and unify variadic argument checking with reqular argument
checking.

Add a check for a new error condition - variadic last argument in
nonvariadic functions, and write a bunch of tests for conditions that we
already check for.

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
gen: rewrite slice and array alloc cases

It was previously spread across two functions that did mostly the same
thing. Also includes some improvements to the actual generated code,
like generating in place whenever possible, and avoiding redoing the
same pointer arithmetic multiple times.

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
gen: extract fixed_abort condition checks into a separate function

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
check: fix measurement error locations

Signed-off-by: Sebastian <sebastian@sebsite.pw>
parse: use error function for empty block error

Besides code deduplication, this also makes harec exit with the correct
status (PARSE instead of FAILURE).

Signed-off-by: Sebastian <sebastian@sebsite.pw>
parse: remove dead branch

Signed-off-by: Sebastian <sebastian@sebsite.pw>
mod: use string initializer instead of memcpy

Signed-off-by: Sebastian <sebastian@sebsite.pw>
main: remove unnecessary 'next' variable

Signed-off-by: Sebastian <sebastian@sebsite.pw>
gen: remove gen_defers from gen_expr_for

For-loop scopes can't have defers, since the grammar only allows for
defers in compound expressions.

Signed-off-by: Sebastian <sebastian@sebsite.pw>
types: make unbounded arrays not assignable to slices

Fixes an abort in gen

Signed-off-by: Sebastian <sebastian@sebsite.pw>
types: remove extraneous check

If both to and from have undefined size and the member types are the
same, then the array types are also the same, meaning it was already
handled above.

Signed-off-by: Sebastian <sebastian@sebsite.pw>
typedef: use const in more places

Signed-off-by: Sebastian <sebastian@sebsite.pw>
gen: fix for-each iterator with tagged union type

Previously, types like (int | str | done) generated incorrect IR, since
tagged union squishing wasn't taken into account.

Signed-off-by: Sebastian <sebastian@sebsite.pw>
check: drop pointless branch

That check is already performed in lower_implicit_cast
Next