]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add regression test for const fn in trait
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 22 Nov 2023 12:22:42 +0000 (13:22 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 30 Jan 2024 11:36:47 +0000 (12:36 +0100)
Const fn declaration in trait declarations shall emit an error. This new
test highlight this behavior.

gcc/testsuite/ChangeLog:

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

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

diff --git a/gcc/testsuite/rust/compile/const_trait_fn.rs b/gcc/testsuite/rust/compile/const_trait_fn.rs
new file mode 100644 (file)
index 0000000..cff2f5f
--- /dev/null
@@ -0,0 +1,4 @@
+trait Osterkz {
+    const fn x();
+    // { dg-error "functions in traits cannot be declared const .E0379." "" { target *-*-* } .-1 }
+}