]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: [E0703] Use of Invalid ABI
authorMuhammad Mahad <mahadtxt@gmail.com>
Thu, 3 Aug 2023 15:46:50 +0000 (20:46 +0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:29 +0000 (19:00 +0100)
Added error code support for invalid ABI.

gcc/rust/ChangeLog:

* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_qualifiers):
called error function.
(ASTLoweringBase::lower_extern_block): likewise.

gcc/testsuite/ChangeLog:

* rust/compile/abi-options1.rs: updated comment for testcase.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
gcc/rust/hir/rust-ast-lower-base.cc
gcc/testsuite/rust/compile/abi-options1.rs

index 4ff49f997f3b120fee2b6306e7f2b7dfdb07091d..da36d75bc67e24f83defa2c7dd5b0911caf936ad 100644 (file)
@@ -702,7 +702,8 @@ ASTLoweringBase::lower_qualifiers (const AST::FunctionQualifiers &qualifiers)
       const std::string &extern_abi = qualifiers.get_extern_abi ();
       abi = get_abi_from_string (extern_abi);
       if (has_extern && abi == ABI::UNKNOWN)
-       rust_error_at (qualifiers.get_locus (), "unknown ABI option");
+       rust_error_at (qualifiers.get_locus (), ErrorCode::E0703,
+                      "invalid ABI: found %qs", extern_abi.c_str ());
     }
 
   return HIR::FunctionQualifiers (qualifiers.get_const_status (), unsafety,
@@ -946,7 +947,8 @@ ASTLoweringBase::lower_extern_block (AST::ExternBlock &extern_block)
       const std::string &extern_abi = extern_block.get_abi ();
       abi = get_abi_from_string (extern_abi);
       if (abi == ABI::UNKNOWN)
-       rust_error_at (extern_block.get_locus (), "unknown ABI option");
+       rust_error_at (extern_block.get_locus (), ErrorCode::E0703,
+                      "invalid ABI: found %qs", extern_abi.c_str ());
     }
 
   HIR::ExternBlock *hir_extern_block
index a4b6241dc159c396577aaf904b762cf45501b504..797dff098234922668e62affd5ec54c3f9991b97 100644 (file)
@@ -1,7 +1,9 @@
 extern "foobar" {
-    // { dg-error "unknown ABI option" "" { target *-*-* } .-1 }
+    // { dg-error "invalid ABI: found .foobar." "" { target *-*-* } .-1 }
     fn printf(s: *const i8, ...);
 }
 
 pub extern "baz" fn test() {}
-// { dg-error "unknown ABI option" "" { target *-*-* } .-1 }
+// { dg-error "invalid ABI: found .baz." "" { target *-*-* } .-1 }
+
+// extern "Rust" fn foo() {} // OK!
\ No newline at end of file