mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Prohibit raw vaargs in regular functions with a function body.
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
- Assert on add to uninitialized ct variable #1765.
|
||||
- Dynamic function lookup fails after changing type without dummy anycast #1761
|
||||
- $vasplat was allowed inside of a function when passed as an argument to a function.
|
||||
- Prohibit raw vaargs in regular functions with a function body.
|
||||
|
||||
### Stdlib changes
|
||||
- Increase BitWriter.write_bits limit up to 32 bits.
|
||||
|
||||
@@ -3161,6 +3161,12 @@ bool sema_analyse_function_body(SemaContext *context, Decl *func)
|
||||
if (!decl_ok(func)) return false;
|
||||
|
||||
Signature *signature = &func->func_decl.signature;
|
||||
if (signature->variadic == VARIADIC_RAW)
|
||||
{
|
||||
RETURN_SEMA_ERROR(func, "C-style variadic arguments '...' are not supported for regular functions,"
|
||||
" please use typed vaargs on the form 'int... args' or "
|
||||
"untyped vaargs on the form 'args...' instead.");
|
||||
}
|
||||
FunctionPrototype *prototype = func->type->function.prototype;
|
||||
ASSERT0(prototype);
|
||||
context->original_inline_line = 0;
|
||||
|
||||
8
test/test_suite/functions/vaarg_raw.c3
Normal file
8
test/test_suite/functions/vaarg_raw.c3
Normal file
@@ -0,0 +1,8 @@
|
||||
import std;
|
||||
|
||||
fn void main()
|
||||
{}
|
||||
|
||||
fn void bohoo(...) // #error: C-style variadic arguments
|
||||
{
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import std;
|
||||
|
||||
def IList = List(<int>);
|
||||
fn IList IList.new(...) @operator(construct)
|
||||
fn IList IList.new() @operator(construct)
|
||||
{
|
||||
IList l;
|
||||
l.new_init($vasplat); // #error: can only be used inside
|
||||
|
||||
Reference in New Issue
Block a user