aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-07-21 14:03:10 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:56:00 +0100
commit3c1cc1190a23f6dc9c5028e1b92e7bbb85651ac3 (patch)
treefeb2c4a6e892540ed509768112c94f534b33135a
parentf02f9672a57f0272996f570a7e8528f832612405 (diff)
downloadgcc-3c1cc1190a23f6dc9c5028e1b92e7bbb85651ac3.zip
gcc-3c1cc1190a23f6dc9c5028e1b92e7bbb85651ac3.tar.gz
gcc-3c1cc1190a23f6dc9c5028e1b92e7bbb85651ac3.tar.bz2
gccrs: Add tests for non function proc_macro_attribute
Add a bunch of test case to avoid regressions on proc_macro_attribute attribute error messages. gcc/testsuite/ChangeLog: * rust/compile/proc_macro_attribute_non_function.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--gcc/testsuite/rust/compile/proc_macro_attribute_non_function.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/proc_macro_attribute_non_function.rs b/gcc/testsuite/rust/compile/proc_macro_attribute_non_function.rs
new file mode 100644
index 0000000..0e88bbe
--- /dev/null
+++ b/gcc/testsuite/rust/compile/proc_macro_attribute_non_function.rs
@@ -0,0 +1,58 @@
+// { dg-additional-options "-frust-crate-type=proc-macro" }
+
+mod inner {
+ struct InnerStruct;
+}
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+type AliasedType = inner::InnerStruct;
+
+// { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" "" { target *-*-* } .+1 }
+#[proc_macro_attribute]
+use inner::InnerStruct;
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+struct MyStruct;
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+struct MyCurlyStruct {
+ member: usize,
+}
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+struct MyTupleStruct(usize);
+
+#[proc_macro_attribute]
+// { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" "" { target *-*-* } .-1 }
+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_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+mod my_module {}
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+enum MyEnum {}
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+union MyUnion {
+ f1: u32,
+ f2: f32,
+}
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+const MY_CONST_STR: &str = "my_string";
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+static MY_STATIC_USIZE: usize = 10;
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+trait MyTrait {}
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+impl MyStruct {}
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+impl MyTrait for MyStruct {}
+
+#[proc_macro_attribute] // { dg-error "the .#.proc_macro_attribute.. attribute may only be used on bare functions" }
+extern "C" {}