diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-05-21 11:36:55 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:34 +0100 |
commit | ea32c9b17fa6485a0a53f12984a976650725a48e (patch) | |
tree | d5aa644fd7e71a19fbb4e277f2d715a4ad63d1c1 | |
parent | 4395d6893473719acd15fbbeab3eb27db2b56dc2 (diff) | |
download | gcc-ea32c9b17fa6485a0a53f12984a976650725a48e.zip gcc-ea32c9b17fa6485a0a53f12984a976650725a48e.tar.gz gcc-ea32c9b17fa6485a0a53f12984a976650725a48e.tar.bz2 |
gccrs: Add some test for raw_ref_op to prevent regressions
Add a test for the feature gate, as well as some test to ensure the raw
keyword stays weak. Also add some tests to check whether the raw_ref_op
syntax is parsed correctly.
gcc/testsuite/ChangeLog:
* rust/compile/not_raw_ref_op.rs: New test.
* rust/compile/raw_ref_op.rs: New test.
* rust/compile/raw_ref_op_feature_gate.rs: New test.
* rust/compile/raw_ref_op_invalid.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | gcc/testsuite/rust/compile/not_raw_ref_op.rs | 9 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/raw_ref_op.rs | 11 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs | 8 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/raw_ref_op_invalid.rs | 12 |
4 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/not_raw_ref_op.rs b/gcc/testsuite/rust/compile/not_raw_ref_op.rs new file mode 100644 index 0000000..f55f184 --- /dev/null +++ b/gcc/testsuite/rust/compile/not_raw_ref_op.rs @@ -0,0 +1,9 @@ +// { dg-options "-frust-compile-until=lowering" } +pub struct Toto { + u: usize, +} + +pub fn test(raw: Toto) { + // Not raw ref op syntax, raw keyword is weak. + let _c = &raw; +} diff --git a/gcc/testsuite/rust/compile/raw_ref_op.rs b/gcc/testsuite/rust/compile/raw_ref_op.rs new file mode 100644 index 0000000..a97e58c --- /dev/null +++ b/gcc/testsuite/rust/compile/raw_ref_op.rs @@ -0,0 +1,11 @@ +// { dg-options "-fsyntax-only" } +#![feature(raw_ref_op)] + +pub struct Toto { + u: usize, +} + +pub fn test(mut toto: Toto) { + let _a = &raw mut toto.u; + let _b = &raw const toto.u; +} diff --git a/gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs b/gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs new file mode 100644 index 0000000..256202b --- /dev/null +++ b/gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs @@ -0,0 +1,8 @@ +// { dg-options "-frust-compile-until=lowering" } +pub struct Toto { + u: usize, +} + +pub fn test(mut toto: Toto) { + let _a = &raw mut toto.u; //{ dg-error "raw address of syntax is experimental." "" { target *-*-* } } +} diff --git a/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs b/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs new file mode 100644 index 0000000..90e169f --- /dev/null +++ b/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs @@ -0,0 +1,12 @@ +// { dg-options "-fsyntax-only" } +#![feature(raw_ref_op)] + +pub struct Toto { + u: usize, +} + +pub fn test(mut toto: Toto) { + let _c = &raw toto.u; //{ dg-error "expecting .;. but .identifier. found" "" { target *-*-* } } + //{ dg-excess-errors "Additional errors for parent items" { target *-*-* } } + +} |