]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add a regression test for function body check
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thu, 23 Nov 2023 13:08:50 +0000 (14:08 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 30 Jan 2024 11:36:48 +0000 (12:36 +0100)
Function body check emit an error message when a required function body
is missing.

gcc/testsuite/ChangeLog:

* rust/compile/functions_without_body.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/testsuite/rust/compile/functions_without_body.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/compile/functions_without_body.rs b/gcc/testsuite/rust/compile/functions_without_body.rs
new file mode 100644 (file)
index 0000000..36ddea5
--- /dev/null
@@ -0,0 +1,21 @@
+struct MyStruct;
+
+trait X {}
+
+fn test_a();
+// { dg-error "free function without a body" "" { target *-*-* } .-1 }
+
+impl MyStruct {
+    fn test_b<T>()
+    // { dg-error "associated function in .impl. without body" "" { target *-*-* } .-1 }
+    where
+        T: Copy;
+
+    fn test_c<T>();
+    // { dg-error "associated function in .impl. without body" "" { target *-*-* } .-1 }
+}
+
+impl X for MyStruct {
+    fn test_d();
+    // { dg-error "associated function in .impl. without body" "" { target *-*-* } .-1 }
+}