Skip to content

Commit

Permalink
Add some test for raw_ref_op to prevent regressions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
P-E-P committed Jun 12, 2024
1 parent bd97356 commit 6fc8ad5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gcc/testsuite/rust/compile/not_raw_ref_op.rs
Original file line number Diff line number Diff line change
@@ -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;
}
11 changes: 11 additions & 0 deletions gcc/testsuite/rust/compile/raw_ref_op.rs
Original file line number Diff line number Diff line change
@@ -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;
}
8 changes: 8 additions & 0 deletions gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs
Original file line number Diff line number Diff line change
@@ -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 *-*-* } }
}
12 changes: 12 additions & 0 deletions gcc/testsuite/rust/compile/raw_ref_op_invalid.rs
Original file line number Diff line number Diff line change
@@ -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 *-*-* } }

}

0 comments on commit 6fc8ad5

Please sign in to comment.