]> gcc.gnu.org Git - gcc.git/commitdiff
Add execution test for name resolution 2.0
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thu, 30 Nov 2023 12:27:01 +0000 (13:27 +0100)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Fri, 1 Dec 2023 13:10:14 +0000 (13:10 +0000)
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>
gcc/testsuite/rust/execute/torture/name_resolution.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/execute/torture/name_resolution.rs b/gcc/testsuite/rust/execute/torture/name_resolution.rs
new file mode 100644 (file)
index 0000000..7492183
--- /dev/null
@@ -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
+}
This page took 0.059512 seconds and 5 git commands to generate.