aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMuhammad Mahad <mahadtxt@gmail.com>2023-07-17 12:32:17 +0500
committerPhilip Herron <philip.herron@embecosm.com>2023-07-17 09:40:02 +0000
commitd7651385b69495089ccb37cb0c76be12aeeec7e7 (patch)
tree17beef9b0b1086fd5aeaaed9e42ad56479367af8 /gcc
parent95e8c2d54f4b865206766db74c178ba134a1ab9d (diff)
downloadgcc-d7651385b69495089ccb37cb0c76be12aeeec7e7.zip
gcc-d7651385b69495089ccb37cb0c76be12aeeec7e7.tar.gz
gcc-d7651385b69495089ccb37cb0c76be12aeeec7e7.tar.bz2
gccrs: [E0423] expected function, tuple struct or tuple variant, found struct
Give error when an identifier was used like a function name or a value was expected and the identifier exists but it belongs to a different namespace. gcc/rust/ChangeLog: * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): called error function. gcc/testsuite/ChangeLog: * rust/compile/found_struct.rs: New test. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-tyty-call.cc2
-rw-r--r--gcc/testsuite/rust/compile/found_struct.rs11
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-call.cc b/gcc/rust/typecheck/rust-tyty-call.cc
index 5493798..7393673 100644
--- a/gcc/rust/typecheck/rust-tyty-call.cc
+++ b/gcc/rust/typecheck/rust-tyty-call.cc
@@ -59,7 +59,7 @@ TypeCheckCallExpr::visit (ADTType &type)
if (variant.get_variant_type () != TyTy::VariantDef::VariantType::TUPLE)
{
rust_error_at (
- call.get_locus (),
+ call.get_locus (), ErrorCode ("E0423"),
"expected function, tuple struct or tuple variant, found struct %<%s%>",
type.get_name ().c_str ());
return;
diff --git a/gcc/testsuite/rust/compile/found_struct.rs b/gcc/testsuite/rust/compile/found_struct.rs
new file mode 100644
index 0000000..66462e6
--- /dev/null
+++ b/gcc/testsuite/rust/compile/found_struct.rs
@@ -0,0 +1,11 @@
+// https://doc.rust-lang.org/error_codes/E0423.html
+#![allow(unused)]
+fn main() {
+ struct Foo {
+ a: bool,
+ };
+
+ let f = Foo(); // { dg-error "expected function, tuple struct or tuple variant, found struct .Foo." }
+ // error: expected function, tuple struct or tuple variant, found `Foo`
+ // `Foo` is a struct name, but this expression uses it like a function name
+}