Skip to content

Commit bb04432

Browse files
committed
fix: typed variadic args
1 parent 0ee2624 commit bb04432

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

grammar.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,14 @@ module.exports = grammar({
660660
$.self,
661661
),
662662

663-
variadic_parameter: _ => '...',
663+
variadic_parameter: $ => seq(
664+
optional($.mutable_specifier),
665+
optional(seq(
666+
field('pattern', $._pattern),
667+
':',
668+
)),
669+
'...',
670+
),
664671

665672
parameter: $ => seq(
666673
optional($.mutable_specifier),

test/corpus/declarations.txt

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ extern "C" fn printf(
290290
...,
291291
) {}
292292

293+
pub unsafe extern "C" fn c_variadic_no_use(fmt: *const i8, mut ap: ...) -> i32 {
294+
// CHECK: call void @llvm.va_start
295+
vprintf(fmt, ap.as_va_list())
296+
// CHECK: call void @llvm.va_end
297+
}
298+
293299
--------------------------------------------------------------------------------
294300

295301
(source_file
@@ -311,7 +317,35 @@ extern "C" fn printf(
311317
(pointer_type
312318
(type_identifier))
313319
(variadic_parameter))
314-
(block)))
320+
(block))
321+
(function_item
322+
(visibility_modifier)
323+
(function_modifiers
324+
(extern_modifier
325+
(string_literal
326+
(string_content))))
327+
(identifier)
328+
(parameters
329+
(parameter
330+
(identifier)
331+
(pointer_type
332+
(primitive_type)))
333+
(variadic_parameter
334+
(mutable_specifier)
335+
(identifier)))
336+
(primitive_type)
337+
(block
338+
(line_comment)
339+
(call_expression
340+
(identifier)
341+
(arguments
342+
(identifier)
343+
(call_expression
344+
(field_expression
345+
(identifier)
346+
(field_identifier))
347+
(arguments))))
348+
(line_comment))))
315349

316350
================================================================================
317351
Use declarations

0 commit comments

Comments
 (0)