aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-07-18 15:43:06 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2023-07-20 08:21:00 +0000
commit242f7a92673e37d4e278174995ae428e03fa3ed0 (patch)
tree51eb75af6640f6bf69a76f3e76208f38e9d20945
parent61fc7f1cb52db1297943807184e344025aed5afe (diff)
downloadgcc-242f7a92673e37d4e278174995ae428e03fa3ed0.zip
gcc-242f7a92673e37d4e278174995ae428e03fa3ed0.tar.gz
gcc-242f7a92673e37d4e278174995ae428e03fa3ed0.tar.bz2
proc macro: Add crate type regression tests
Add several tests to prevent regression with proc_macro, proc_macro_derive and proc_macro_attribute attributes error messages. gcc/testsuite/ChangeLog: * rust/compile/proc_macro_attribute_crate_type.rs: New test. * rust/compile/proc_macro_crate_type.rs: New test. * rust/compile/proc_macro_derive_crate_type.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--gcc/testsuite/rust/compile/proc_macro_attribute_crate_type.rs4
-rw-r--r--gcc/testsuite/rust/compile/proc_macro_crate_type.rs4
-rw-r--r--gcc/testsuite/rust/compile/proc_macro_derive_crate_type.rs6
3 files changed, 14 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/proc_macro_attribute_crate_type.rs b/gcc/testsuite/rust/compile/proc_macro_attribute_crate_type.rs
new file mode 100644
index 0000000..9ffd2b0
--- /dev/null
+++ b/gcc/testsuite/rust/compile/proc_macro_attribute_crate_type.rs
@@ -0,0 +1,4 @@
+// { dg-additional-options "-frust-crate-type=lib" }
+
+#[proc_macro_attribute] // { dg-excess-errors "the '#\[proc_macro_attribute\]' attribute is only usable with crates of the 'proc-macro' crate type" }
+pub fn my_invalid_macro() {}
diff --git a/gcc/testsuite/rust/compile/proc_macro_crate_type.rs b/gcc/testsuite/rust/compile/proc_macro_crate_type.rs
new file mode 100644
index 0000000..f27a94a
--- /dev/null
+++ b/gcc/testsuite/rust/compile/proc_macro_crate_type.rs
@@ -0,0 +1,4 @@
+// { dg-additional-options "-frust-crate-type=lib" }
+
+#[proc_macro] // { dg-excess-errors "the '#\[proc_macro\]' attribute is only usable with crates of the 'proc-macro' crate type" }
+pub fn my_invalid_macro() {}
diff --git a/gcc/testsuite/rust/compile/proc_macro_derive_crate_type.rs b/gcc/testsuite/rust/compile/proc_macro_derive_crate_type.rs
new file mode 100644
index 0000000..20f6997
--- /dev/null
+++ b/gcc/testsuite/rust/compile/proc_macro_derive_crate_type.rs
@@ -0,0 +1,6 @@
+// { dg-additional-options "-frust-crate-type=lib" }
+
+trait Dungeness {}
+
+#[proc_macro_derive(Dungeness)] // { dg-excess-errors "the '#\[proc_macro_derive\]' attribute is only usable with crates of the 'proc-macro' crate type" }
+pub fn my_invalid_macro() {}