From d9d7f79a422f8669a5a7e6d627c764ba9f3eded9 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 17 Jan 2024 13:02:51 +0100 Subject: gccrs: Add tuple struct constructor to value namespace A tuple struct constructor should be inserted in the value namespace during name resolution in order to reject multiple definitions of the function. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add the struct constructor to the value namespace. gcc/testsuite/ChangeLog: * rust/compile/name_resolution22.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 3 +++ gcc/testsuite/rust/compile/name_resolution22.rs | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 gcc/testsuite/rust/compile/name_resolution22.rs (limited to 'gcc') diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc index 6929bdb..4134b9a 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc @@ -337,6 +337,9 @@ TopLevel::visit (AST::TupleStruct &tuple_struct) { insert_or_error_out (tuple_struct.get_struct_name (), tuple_struct, Namespace::Types); + + insert_or_error_out (tuple_struct.get_struct_name (), tuple_struct, + Namespace::Values); } void diff --git a/gcc/testsuite/rust/compile/name_resolution22.rs b/gcc/testsuite/rust/compile/name_resolution22.rs new file mode 100644 index 0000000..c49331e --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution22.rs @@ -0,0 +1,5 @@ +// { dg-options "-frust-name-resolution-2.0" } +struct Marker; +struct Foo(Marker); + +fn Foo(m: Marker) {} // { dg-error ".Foo. defined multiple times" } -- cgit v1.1