diff options
author | David Faust <david.faust@oracle.com> | 2022-01-20 12:43:51 -0800 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2022-01-20 12:53:23 -0800 |
commit | b4587fb281d3066e4591a5067e2fa9a79df272aa (patch) | |
tree | ed72786f6e720f99e1648233c86bf2c77d9c393c /gcc | |
parent | b02824c6a798a78657568e7d831bd10529d63e37 (diff) | |
download | gcc-b4587fb281d3066e4591a5067e2fa9a79df272aa.zip gcc-b4587fb281d3066e4591a5067e2fa9a79df272aa.tar.gz gcc-b4587fb281d3066e4591a5067e2fa9a79df272aa.tar.bz2 |
Record correct location when compiling ADT types
When compiling ADTTypes, the wrong HirId was being used for location
lookup. This produced an issue where the gimple dump would not write
type names for struct and union types, because they were mistaken for
built-in types.
Also add new test testsuite/rust/compile/torture/struct_decl.rs.
Fixes: #877
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/backend/rust-compile-type.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/struct_decl.rs | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc index d7a8ae5..708f850 100644 --- a/gcc/rust/backend/rust-compile-type.cc +++ b/gcc/rust/backend/rust-compile-type.cc @@ -281,7 +281,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) tree named_struct = ctx->get_backend ()->named_type (type.get_name (), type_record, ctx->get_mappings ()->lookup_location ( - type.get_ty_ref ())); + type.get_ref ())); ctx->push_type (named_struct); translated = named_struct; diff --git a/gcc/testsuite/rust/compile/torture/struct_decl.rs b/gcc/testsuite/rust/compile/torture/struct_decl.rs new file mode 100644 index 0000000..3966928 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/struct_decl.rs @@ -0,0 +1,14 @@ +// { dg-additional-options -fdump-tree-gimple } + +struct Foo { + a: u16, +// { dg-warning "field is never read" "" { target *-*-* } .-1 } + b: u8, +// { dg-warning "field is never read" "" { target *-*-* } .-1 } +} + +fn main() { + let my_foo = Foo { a: 1, b: 2 }; + // { dg-warning "unused name" "" { target *-*-* } .-1 } + // { dg-final { scan-tree-dump-times {(?n)const struct Foo my_foo;$} 1 gimple } } +} |