Skip to content

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 <[email protected]>
@CohenArthur CohenArthur added enhancement diagnostic diagnostic static analysis labels Jul 20, 2023
@CohenArthur CohenArthur requested a review from philberty July 20, 2023 09:07
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
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