[COMMITTED 061/101] gccrs: Add execution test for name resolution 2.0

arthur.cohen@embecosm.com arthur.cohen@embecosm.com
Tue Jan 30 12:07:17 GMT 2024


From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

We already have some compile tests but it lacked an execution test to
ensure everything compiles correctly to the correct value.

gcc/testsuite/ChangeLog:

	* rust/execute/torture/name_resolution.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
---
 .../rust/execute/torture/name_resolution.rs   | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 gcc/testsuite/rust/execute/torture/name_resolution.rs

diff --git a/gcc/testsuite/rust/execute/torture/name_resolution.rs b/gcc/testsuite/rust/execute/torture/name_resolution.rs
new file mode 100644
index 00000000000..749218352d6
--- /dev/null
+++ b/gcc/testsuite/rust/execute/torture/name_resolution.rs
@@ -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
+}
-- 
2.42.1



More information about the Gcc-rust mailing list