From 119e0be8b6eea63a95c89d449c38aa133e6ad5ab Mon Sep 17 00:00:00 2001
From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Thu, 9 Nov 2023 15:45:04 +0100
Subject: [PATCH] gccrs: Add regression test for invalid label name

An error message should be emitted when the rust code contains invalid
label name. Add a new test for this behavior.

gcc/testsuite/ChangeLog:

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

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

diff --git a/gcc/testsuite/rust/compile/invalid_label_name.rs b/gcc/testsuite/rust/compile/invalid_label_name.rs
new file mode 100644
index 000000000000..5c850da636cb
--- /dev/null
+++ b/gcc/testsuite/rust/compile/invalid_label_name.rs
@@ -0,0 +1,23 @@
+pub fn function() {
+    'continue: loop {
+        // { dg-error "invalid label name .'continue." "" { target *-*-* } .-1 }
+        break 'extern;
+        // { dg-error "invalid label name .'extern." "" { target *-*-* } .-1 }
+    }
+
+    'break: loop {
+        // { dg-error "invalid label name .'break." "" { target *-*-* } .-1 }
+        break 'for;
+        // { dg-error "invalid label name .'for." "" { target *-*-* } .-1 }
+    }
+
+    'crate: loop {
+        // { dg-error "invalid label name .'crate." "" { target *-*-* } .-1 }
+        break 'loop;
+        // { dg-error "invalid label name .'loop." "" { target *-*-* } .-1 }
+    }
+
+    'a: loop {
+        break 'a;
+    }
+}
-- 
GitLab