Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for binding name resolution scope #2766

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution11.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// { dg-additional-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" }
fn foo() {
let b = 10;
fn bar() {
let a = foo;
}
}
10 changes: 10 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution12.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// { dg-additional-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" }

const TOTO: i32 = 10;

fn foo() {
let b = 10;
fn bar() {
let e = TOTO;
}
}
9 changes: 9 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution13.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// { dg-additional-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" }

fn foo() {
let b = 10;
fn bar() {
let c = b;
// { dg-error "cannot find value .b. in this scope .E0425." "" { target *-*-* } .-1 }
}
}
24 changes: 24 additions & 0 deletions gcc/testsuite/rust/execute/torture/name_resolution.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// { dg-additional-options "-frust-name-resolution-2.0" }
// { dg-output "Value is 10\r*\n" }

const BAZ: i32 = 10;

extern "C" {
fn printf(s: *const i8, ...);
}

fn foo() {
fn bar() {
let e = BAZ;
unsafe {
printf("Value is %i\n" as *const str as *const i8, e);
}
}

bar();
}

fn main() -> i32 {
foo();
0
}