aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-07-21 13:32:53 +0200
committerCohenArthur <arthur.cohen@embecosm.com>2023-07-27 09:40:30 +0000
commitd6eb8f3841671e6d2d65ca8cee311d1bdf39149d (patch)
tree690cb18273d647b11c1461898a00d4ea29fda308 /gcc
parentdc9eaa15e986ed104f3416014b1d0cdd97896960 (diff)
downloadgcc-d6eb8f3841671e6d2d65ca8cee311d1bdf39149d.zip
gcc-d6eb8f3841671e6d2d65ca8cee311d1bdf39149d.tar.gz
gcc-d6eb8f3841671e6d2d65ca8cee311d1bdf39149d.tar.bz2
Add tests for non function proc_macro attributes
Add a bunch of test cases to avoid regressions on attribute error message. gcc/testsuite/ChangeLog: * rust/compile/proc_macro_non_function.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/rust/compile/proc_macro_non_function.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/proc_macro_non_function.rs b/gcc/testsuite/rust/compile/proc_macro_non_function.rs
new file mode 100644
index 0000000..ff2083c
--- /dev/null
+++ b/gcc/testsuite/rust/compile/proc_macro_non_function.rs
@@ -0,0 +1,57 @@
+// { dg-additional-options "-frust-crate-type=proc-macro" }
+
+mod inner {
+ struct InnerStruct;
+}
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+type AliasedType = inner::InnerStruct;
+
+// { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" "" { target *-*-* } .+1 }
+#[proc_macro]
+use inner::InnerStruct;
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+struct MyStruct;
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+struct MyCurlyStruct {
+ member: usize,
+}
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+struct MyTupleStruct(usize);
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+extern crate my_extern_crate; // { dg-error "unknown crate .my_extern_crate." }
+ // { dg-error "failed to locate crate .my_extern_crate." "" { target *-*-* } .-1 }
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+mod my_module {}
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+enum MyEnum {}
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+union MyUnion {
+ f1: u32,
+ f2: f32,
+}
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+const MY_CONST_STR: &str = "my_string";
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+static MY_STATIC_USIZE: usize = 10;
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+trait MyTrait {}
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+impl MyStruct {}
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+impl MyTrait for MyStruct {}
+
+#[proc_macro] // { dg-error "the .#.proc_macro.. attribute may only be used on bare functions" }
+extern "C" {}