public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7831] gccrs: [E0045] Variadic Parameters Used on Non-C ABI Function
@ 2024-01-16 18:02 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:02 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:da58dc1a33dea1fea05636003118ef8d50fdb5f7
commit r14-7831-gda58dc1a33dea1fea05636003118ef8d50fdb5f7
Author: Muhammad Mahad <mahadtxt@gmail.com>
Date: Wed Jul 19 15:49:25 2023 +0500
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>
Diff:
---
gcc/rust/typecheck/rust-hir-type-check-implitem.cc | 10 +++++++++-
gcc/testsuite/rust/compile/abi-vardaic.rs | 7 +++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
index 189dd8797d1..92868b9e343 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 00000000000..b5e0c9a9eff
--- /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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 18:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:02 [gcc r14-7831] gccrs: [E0045] Variadic Parameters Used on Non-C ABI Function Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).