]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Emit an error on variadic non extern functions
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 20 Nov 2023 10:19:46 +0000 (11:19 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 30 Jan 2024 11:36:44 +0000 (12:36 +0100)
Variadic regular functions were recently added in the parser as they
should be rejected in the ast validation pass. This commit add the ast
validation pass rejecting this kind of variadic arguments.

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add
ast validation pass to reject variadic arguments on regular functions.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/checks/errors/rust-ast-validation.cc

index 673290959f4bd46ded89f5d28db134a847db1a2c..4142cc6317ee22847108c43e611953a9161b02d0 100644 (file)
@@ -93,6 +93,11 @@ ASTValidation::visit (AST::Function &function)
       function.get_self_param ()->get_locus (),
       "%<self%> parameter is only allowed in associated functions");
 
+  if (function.is_variadic ())
+    rust_error_at (
+      function.get_function_params ().back ()->get_locus (),
+      "only foreign or %<unsafe extern \"C\"%> functions may be C-variadic");
+
   AST::ContextualASTVisitor::visit (function);
 }