Commit Message
Arthur Cohen
Aug. 1, 2024, 2:57 p.m. UTC
From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> 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 <pierre-emmanuel.patry@embecosm.com> --- 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
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 6929bdb641e..4134b9a4620 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 00000000000..c49331ef38c --- /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" }