diff options
author | Muhammad Mahad <mahadtxt@gmail.com> | 2023-07-19 15:49:25 +0500 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-07-27 09:08:13 +0000 |
commit | 7cfba279dad9cf5e193b29cb34691156ee3fb221 (patch) | |
tree | a9a46cfc95a1fe9525f83ecf2db3064da39443c3 | |
parent | 245867e9999c11be2a725156cead914ad402059e (diff) | |
download | gcc-7cfba279dad9cf5e193b29cb34691156ee3fb221.zip gcc-7cfba279dad9cf5e193b29cb34691156ee3fb221.tar.gz gcc-7cfba279dad9cf5e193b29cb34691156ee3fb221.tar.bz2 |
gccrs: [E0045] Variadic Parameters Used on Non-C ABI Function
Added error code support for using variadic parameters used
on Non-C ABI function. Fixes #2382
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit):
Added check for error code support.
gcc/testsuite/ChangeLog:
* rust/compile/abi-vardaic.rs: New test.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-implitem.cc | 10 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/abi-vardaic.rs | 7 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc index 5a0ffef..f54aceb 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc @@ -138,7 +138,15 @@ TypeCheckTopLevelExternItem::visit (HIR::ExternalFunctionItem &function) uint8_t flags = TyTy::FnType::FNTYPE_IS_EXTERN_FLAG; if (function.is_variadic ()) - flags |= TyTy::FnType::FNTYPE_IS_VARADIC_FLAG; + { + flags |= TyTy::FnType::FNTYPE_IS_VARADIC_FLAG; + if (parent.get_abi () != Rust::ABI::C) + { + rust_error_at ( + function.get_locus (), ErrorCode ("E0045"), + "C-variadic function must have C or cdecl calling convention"); + } + } RustIdent ident{ CanonicalPath::new_seg (function.get_mappings ().get_nodeid (), diff --git a/gcc/testsuite/rust/compile/abi-vardaic.rs b/gcc/testsuite/rust/compile/abi-vardaic.rs new file mode 100644 index 0000000..b5e0c9a --- /dev/null +++ b/gcc/testsuite/rust/compile/abi-vardaic.rs @@ -0,0 +1,7 @@ +// https://doc.rust-lang.org/error_codes/E0045.html +#![allow(unused)] +fn main() { + extern "Rust" { + fn foo(x: u8, ...); // { dg-error "C-variadic function must have C or cdecl calling convention" } + } +}
\ No newline at end of file |