From fe0ae4a9aa3702f7d97cfa852f34da19f8725831 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 4 Sep 2023 22:24:46 +0200 Subject: [PATCH] Error when splat is used with raw varargs. --- src/compiler/sema_expr.c | 4 ++++ src/version.h | 2 +- test/test_suite/functions/splat_raw.c3 | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/test_suite/functions/splat_raw.c3 diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index a95a42bf9..46b1d5cc8 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -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", diff --git a/src/version.h b/src/version.h index 569769467..9821039c7 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.631" \ No newline at end of file +#define COMPILER_VERSION "0.4.632" \ No newline at end of file diff --git a/test/test_suite/functions/splat_raw.c3 b/test/test_suite/functions/splat_raw.c3 new file mode 100644 index 000000000..6fd5fbed0 --- /dev/null +++ b/test/test_suite/functions/splat_raw.c3 @@ -0,0 +1,8 @@ + + +extern fn void foo(int x, ...); + +fn void test(void*... y) +{ + foo(1, ...y); // #error: raw varargs +} \ No newline at end of file