mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Compiler assert with typed macro vaargs accessing a macro passed as vaarg #2498
This commit is contained in:
@@ -1656,6 +1656,10 @@ bool parse_parameters(ParseContext *c, Decl ***params_ref, Variadic *variadic, i
|
||||
print_error_after(c->prev_span, "Expected a parameter.");
|
||||
return false;
|
||||
}
|
||||
if (parse_kind == PARAM_PARSE_MACRO && ellipsis && type)
|
||||
{
|
||||
print_error_after(c->prev_span, "A typed macro vaarg must have a parameter name.");
|
||||
}
|
||||
no_name = true;
|
||||
span = c->prev_span;
|
||||
param_kind = VARDECL_PARAM;
|
||||
|
||||
@@ -2681,7 +2681,7 @@ static inline bool sema_expr_setup_call_analysis(SemaContext *context, CalledDec
|
||||
expr->expr_other_context.inner = expr_inner;
|
||||
expr->expr_other_context.context = context;
|
||||
}
|
||||
macro_context->macro_varargs = callee->macro ? call_expr->call_expr.varargs : NULL;
|
||||
macro_context->macro_varargs = callee->macro && callee->signature->variadic == VARIADIC_RAW ? call_expr->call_expr.varargs : NULL;
|
||||
macro_context->original_inline_line = context->original_inline_line ? context->original_inline_line : call_expr->span.row;
|
||||
macro_context->original_module = context->original_module ? context->original_module : context->compilation_unit->module;
|
||||
macro_context->macro_params = params;
|
||||
|
||||
16
test/test_suite/functions/vaarg_no_name_macro.c3
Normal file
16
test/test_suite/functions/vaarg_no_name_macro.c3
Normal file
@@ -0,0 +1,16 @@
|
||||
module test;
|
||||
import std;
|
||||
fn int main(String[] args)
|
||||
{
|
||||
test2(test1(1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
macro String test1(a) => "abc";
|
||||
|
||||
macro test2(String...) // #error: must have a parameter name
|
||||
{
|
||||
$for var $i = 0; $i < $vacount; $i++:
|
||||
io::printfn($vaarg[$i]);
|
||||
$endfor
|
||||
}
|
||||
Reference in New Issue
Block a user