Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E0045] Variadic Parameters Used on Non-C ABI Function #2451

Merged

Conversation

MahadMuhammad
Copy link
Contributor

Variadic Parameters Used on Non-C ABI Function - E0045


Code tested from E0045

// 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" }
    }
}

Output:

➜  gccrs-build gcc/crab1 /home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/abi-vardaic.rs                           
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/abi-vardaic.rs:5:9: error: C-variadic function must have C or cdecl calling convention [E0045]
    5 |         fn foo(x: u8, ...); // { dg-error "C-variadic function must have C or cdecl calling convention" }
      |         ^~

Analyzing compilation unit

Time variable                                   usr           sys          wall           GGC
 TOTAL                              :   0.00          0.00          0.00          146k
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --enable-checking=release to disable checks.

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.

Added error code support for using variadic parameters used
on Non-C ABI function. Fixes Rust-GCC#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>
@CohenArthur CohenArthur added enhancement diagnostic diagnostic static analysis labels Jul 20, 2023
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@CohenArthur CohenArthur added this pull request to the merge queue Jul 27, 2023
Merged via the queue into Rust-GCC:master with commit 7cfba27 Jul 27, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostic diagnostic static analysis enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error Variadic Parameters - [E0045]
3 participants