Skip to content

Commit

Permalink
Error when splat is used with raw varargs.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Sep 4, 2023
1 parent d1bb9c5 commit fe0ae4a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/compiler/sema_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,10 @@ static inline bool sema_call_analyse_invocation(SemaContext *context, Expr *call
if (!sema_analyse_expr(context, vararg_splat)) return false;

// 11d. If it is allowed.
if (!variadic_type)
{
RETURN_SEMA_ERROR(vararg_splat, "Splat may not be used with raw varargs.");
}
if (!expr_may_splat_as_vararg(vararg_splat, variadic_type))
{
SEMA_ERROR(vararg_splat, "It's not possible to splat %s as vararg of type %s",
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define COMPILER_VERSION "0.4.631"
#define COMPILER_VERSION "0.4.632"
8 changes: 8 additions & 0 deletions test/test_suite/functions/splat_raw.c3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


extern fn void foo(int x, ...);

fn void test(void*... y)
{
foo(1, ...y); // #error: raw varargs
}

0 comments on commit fe0ae4a

Please sign in to comment.