aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-11-20 11:19:46 +0100
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2023-11-21 11:16:34 +0000
commit33965b86fe26e1f352a6dc2a18d88b25a0b36ada (patch)
treef08a70d1d78bf83bf0104cbc64e7bc610e19dfc0 /gcc
parentb1b0de60cd99742eb71dd909969e128ea0cd94ef (diff)
downloadgcc-33965b86fe26e1f352a6dc2a18d88b25a0b36ada.zip
gcc-33965b86fe26e1f352a6dc2a18d88b25a0b36ada.tar.gz
gcc-33965b86fe26e1f352a6dc2a18d88b25a0b36ada.tar.bz2
Emit an error on variadic non extern functions
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/checks/errors/rust-ast-validation.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc
index 6732909..4142cc6 100644
--- a/gcc/rust/checks/errors/rust-ast-validation.cc
+++ b/gcc/rust/checks/errors/rust-ast-validation.cc
@@ -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);
}