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

Error Variadic Parameters - [E0045] #2382

Closed
MahadMuhammad opened this issue Jul 5, 2023 · 3 comments · Fixed by #2451
Closed

Error Variadic Parameters - [E0045] #2382

MahadMuhammad opened this issue Jul 5, 2023 · 3 comments · Fixed by #2451

Comments

@MahadMuhammad
Copy link
Contributor

Variadic Parameters Used on Non-C ABI Function

  • Fixing this error will improve gccrs to emit error codes similiar to rustc.
  • You can view the same on compiler-explorer

I tried this code from E0045:

// https://doc.rust-lang.org/error_codes/E0045.html
#![allow(unused)]
fn main() {
extern "Rust" {
    fn foo(x: u8, ...); // error!
}
}

I expected to see this happen:

  • Give error like rustc:
error[E0045]: C-variadic function must have C or cdecl calling convention
 --> <source>:4:5
  |
4 |     fn foo(x: u8, ...); // error!
  |     ^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention

error: aborting due to previous error

For more information about this error, try `rustc --explain E0045`.
Compiler returned: 1

Instead, this happened:

  • Compiled Successfully.
Compiler returned: 0

Meta

  • What version of Rust GCC were you using, git sha 5406b63.
  • Godbolt version : gccrs (Compiler-Explorer-Build-gcc-2f91d511200bf85558c9013b09a458c06edd1e02-binutils-2.40) 13.0.1 20230417 (experimental)

@MahadMuhammad MahadMuhammad changed the title Error Variadic Paramters - [E0045] Error Variadic Parameters - [E0045] Jul 5, 2023
@philberty
Copy link
Member

philberty commented Jul 6, 2023

We need to add an ABI check in type check of call expressions:

https://github.com/Rust-GCC/gccrs/blob/5406b633a1f5e6e3ae8da02589adf4ea003dec12/gcc/rust/typecheck/rust-tyty-call.cc#L92C30-L92C30

we can check of the function we are type checking is varadic this is missing another if statement for:

if (type.get_abi () != ABI::C)

@philberty
Copy link
Member

@MahadMuhammad ^^^

MahadMuhammad added a commit to MahadMuhammad/gccrs that referenced this issue Jul 18, 2023
Fixes  Rust-GCC#2382
[skip actions]

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit):
	Added error code support.

gcc/testsuite/ChangeLog:

	* rust/compile/abi-vardaic.rs: New test.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
@philberty
Copy link
Member

auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (),

MahadMuhammad added a commit to MahadMuhammad/gccrs that referenced this issue Jul 19, 2023
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>
github-merge-queue bot pushed a commit that referenced this issue Jul 27, 2023
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>
CohenArthur pushed a commit to CohenArthur/gccrs that referenced this issue Nov 15, 2023
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 pushed a commit to CohenArthur/gccrs that referenced this issue Nov 21, 2023
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 pushed a commit to CohenArthur/gccrs that referenced this issue Nov 21, 2023
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 5, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 8, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 9, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 11, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 12, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 16, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 16, 2024
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 pushed a commit to CohenArthur/gccrs that referenced this issue Jan 17, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants