]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Fri, 1 Dec 2023 09:26:43 +0000 (09:26 +0000)
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 }
+}