Skip to content

Commit 6aa0b64

Browse files
committed
gccrs: Fix bug with non compiled const decl
There was a sily bug where if you reorder this test case to declare A before B this test would work but its meant to work in any order. So this fixes the bug during code gen to fall back to our query compile system if this is needed. Fixes #3525 gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc: if this fails fall back to query compile gcc/testsuite/ChangeLog: * rust/compile/issue-3525.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
1 parent 1f1fefe commit 6aa0b64

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

gcc/rust/backend/rust-compile-resolve-path.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,18 @@ ResolvePathRef::resolve_with_node_id (
187187
}
188188

189189
// Handle unit struct
190+
tree resolved_item = error_mark_node;
190191
if (lookup->get_kind () == TyTy::TypeKind::ADT)
191-
return attempt_constructor_expression_lookup (lookup, ctx, mappings,
192-
expr_locus);
192+
resolved_item
193+
= attempt_constructor_expression_lookup (lookup, ctx, mappings,
194+
expr_locus);
195+
196+
if (!error_operand_p (resolved_item))
197+
return resolved_item;
193198

194199
// let the query system figure it out
195-
tree resolved_item = query_compile (ref, lookup, final_segment, mappings,
196-
expr_locus, is_qualified_path);
200+
resolved_item = query_compile (ref, lookup, final_segment, mappings,
201+
expr_locus, is_qualified_path);
197202
if (resolved_item != error_mark_node)
198203
{
199204
TREE_USED (resolved_item) = 1;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// { dg-options "-w" }
2+
3+
struct Foo(usize);
4+
5+
const B: usize = A.0;
6+
const A: Foo = Foo(123);

0 commit comments

Comments
 (0)