aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-06-23 12:59:33 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-08-05 16:36:51 +0200
commit6e5e0c1fd943d77aac9f21fc343e1f5b732eca1c (patch)
treecf00f2c81b9027e7b1533ebd456830f60e7a8a40 /gcc
parentdd4eabb87bff25a1a1ad5fc7b8f2da7cce8e0e47 (diff)
downloadgcc-6e5e0c1fd943d77aac9f21fc343e1f5b732eca1c.zip
gcc-6e5e0c1fd943d77aac9f21fc343e1f5b732eca1c.tar.gz
gcc-6e5e0c1fd943d77aac9f21fc343e1f5b732eca1c.tar.bz2
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 Rust-GCC#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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.cc13
-rw-r--r--gcc/testsuite/rust/compile/issue-3525.rs6
2 files changed, 15 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc
index 81d2dbb..1ce9676 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.cc
+++ b/gcc/rust/backend/rust-compile-resolve-path.cc
@@ -187,13 +187,18 @@ ResolvePathRef::resolve_with_node_id (
}
// Handle unit struct
+ tree resolved_item = error_mark_node;
if (lookup->get_kind () == TyTy::TypeKind::ADT)
- return attempt_constructor_expression_lookup (lookup, ctx, mappings,
- expr_locus);
+ resolved_item
+ = attempt_constructor_expression_lookup (lookup, ctx, mappings,
+ expr_locus);
+
+ if (!error_operand_p (resolved_item))
+ return resolved_item;
// let the query system figure it out
- tree resolved_item = query_compile (ref, lookup, final_segment, mappings,
- expr_locus, is_qualified_path);
+ resolved_item = query_compile (ref, lookup, final_segment, mappings,
+ expr_locus, is_qualified_path);
if (resolved_item != error_mark_node)
{
TREE_USED (resolved_item) = 1;
diff --git a/gcc/testsuite/rust/compile/issue-3525.rs b/gcc/testsuite/rust/compile/issue-3525.rs
new file mode 100644
index 0000000..84a7ebe
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3525.rs
@@ -0,0 +1,6 @@
+// { dg-options "-w" }
+
+struct Foo(usize);
+
+const B: usize = A.0;
+const A: Foo = Foo(123);