diff options
Diffstat (limited to 'gcc/testsuite/rust/compile')
24 files changed, 163 insertions, 38 deletions
diff --git a/gcc/testsuite/rust/compile/black_box.rs b/gcc/testsuite/rust/compile/black_box.rs new file mode 100644 index 0000000..80615af --- /dev/null +++ b/gcc/testsuite/rust/compile/black_box.rs @@ -0,0 +1,28 @@ +// { dg-options "-fdump-tree-gimple" } +#![feature(rustc_attrs)] + +#[lang = "sized"] +pub trait Sized {} + +#[rustc_builtin_macro] +macro_rules! llvm_asm { + () => {}; +} + +pub fn black_box<T>(mut dummy: T) -> T { + unsafe { + // { dg-final { scan-tree-dump-times {memory} 1 gimple } } + llvm_asm!("" : : "r"(&mut dummy) : "memory" : "volatile"); + } + + dummy +} + +fn my_function(a: i32) -> i32 { + a +} + +fn main() { + let dummy: i32 = 42; + let _ = black_box(my_function(dummy)); +} diff --git a/gcc/testsuite/rust/compile/derive-debug1.rs b/gcc/testsuite/rust/compile/derive-debug1.rs index 2596a37..cf2187d 100644 --- a/gcc/testsuite/rust/compile/derive-debug1.rs +++ b/gcc/testsuite/rust/compile/derive-debug1.rs @@ -15,7 +15,7 @@ mod core { struct Formatter; // { dg-warning "is never constructed" } struct Error; // { dg-warning "is never constructed" } - type Result = core::result::Result<(), Error>; + type Result = crate::core::result::Result<(), Error>; trait Debug { fn fmt(&self, fmt: &mut Formatter) -> Result; diff --git a/gcc/testsuite/rust/compile/generics9.rs b/gcc/testsuite/rust/compile/generics9.rs index 3c787aa..56c6198 100644 --- a/gcc/testsuite/rust/compile/generics9.rs +++ b/gcc/testsuite/rust/compile/generics9.rs @@ -1,5 +1,6 @@ +// { dg-additional-options "-frust-name-resolution-2.0" } struct Foo<A, B = (A, B)>(A, B); -// { dg-error "could not resolve type path .B." "" { target *-*-* } .-1 } +// { dg-error "type parameters with a default cannot use forward declared identifiers" "" { target *-*-* } .-1 } fn main() { let a: Foo<bool>; diff --git a/gcc/testsuite/rust/compile/issue-3530-1.rs b/gcc/testsuite/rust/compile/issue-3530-1.rs new file mode 100644 index 0000000..b38b5cd --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3530-1.rs @@ -0,0 +1,2 @@ +#[repr(i32)] +enum NightsWatch {} // { dg-error "unsupported representation for zero-variant enum" } diff --git a/gcc/testsuite/rust/compile/issue-3530-2.rs b/gcc/testsuite/rust/compile/issue-3530-2.rs new file mode 100644 index 0000000..7432730 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3530-2.rs @@ -0,0 +1,2 @@ +#[repr(C)] +enum NightsWatch {} // { dg-error "unsupported representation for zero-variant enum" } diff --git a/gcc/testsuite/rust/compile/issue-3568.rs b/gcc/testsuite/rust/compile/issue-3568.rs index 222a174..fef43b5 100644 --- a/gcc/testsuite/rust/compile/issue-3568.rs +++ b/gcc/testsuite/rust/compile/issue-3568.rs @@ -4,4 +4,4 @@ mod foo { } pub use foo::super::foo::S as T; -// { dg-error ".super. can only be used in start position" "" { target *-*-* } .-1 } +// { dg-error ".super. in paths can only be used in start position" "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/rust/compile/issue-3581-1.rs b/gcc/testsuite/rust/compile/issue-3581-1.rs new file mode 100644 index 0000000..eb2f5f0 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3581-1.rs @@ -0,0 +1,12 @@ +enum Foo { + Bar, +} + +struct Baz; + +fn main() { + Foo::Bar.a; + // { dg-error "no field .a. on type .Foo. .E0609." "" { target *-*-* } .-1 } + Baz.a; + // { dg-error "no field .a. on type .Baz. .E0609." "" { target *-*-* } .-1 } +} diff --git a/gcc/testsuite/rust/compile/issue-3581-2.rs b/gcc/testsuite/rust/compile/issue-3581-2.rs new file mode 100644 index 0000000..5059784 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3581-2.rs @@ -0,0 +1,9 @@ +enum A { + X { inner: i32 }, + Y, +} + +pub fn test() { + let _ = A::Y.inner; + // { dg-error "no field .inner. on type .A. .E0609." "" { target *-*-* } .-1 } +} diff --git a/gcc/testsuite/rust/compile/issue-3612.rs b/gcc/testsuite/rust/compile/issue-3612.rs new file mode 100644 index 0000000..5256d0a --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3612.rs @@ -0,0 +1,7 @@ +trait _St1 { + pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; + // { dg-error "no method named .as_ptr. found in the current scope .E0599." "" { target *-*-* } .-1 } + // { dg-error "failed to resolve receiver in MethodCallExpr" "" { target *-*-* } .-2 } +} + +fn main() {} diff --git a/gcc/testsuite/rust/compile/issue-3628.rs b/gcc/testsuite/rust/compile/issue-3628.rs new file mode 100644 index 0000000..5f59789 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3628.rs @@ -0,0 +1,10 @@ +pub enum Enum { + Variant1(isize), +} + +impl Enum { + fn static_meth_enum() -> Enum { + Enum { x: 1 } + // { dg-error "expected a struct, variant or union type, found enum .Enum. .E0574." "" { target *-*-* } .-1 } + } +} diff --git a/gcc/testsuite/rust/compile/issue-3649.rs b/gcc/testsuite/rust/compile/issue-3649.rs new file mode 100644 index 0000000..b85b193 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3649.rs @@ -0,0 +1,2 @@ +struct T(Box<>); +// { dg-error "could not resolve type path .Box. .E0412." "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/rust/compile/issue-3652.rs b/gcc/testsuite/rust/compile/issue-3652.rs new file mode 100644 index 0000000..537ca9f --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3652.rs @@ -0,0 +1,7 @@ +trait Foo { + type T; + fn foo() -> T<<Self as Foo>::T>; + // { dg-error "could not resolve type path .T. .E0412." "" { target *-*-* } .-1 } +} + +fn foo() {} diff --git a/gcc/testsuite/rust/compile/issue-3662.rs b/gcc/testsuite/rust/compile/issue-3662.rs new file mode 100644 index 0000000..88baa2e --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3662.rs @@ -0,0 +1,8 @@ +pub fn rlib() { + let _ = ((-1 as i8) << 8 - 1) as f32; + let _ = 0u8 as char; + let _ = true > false; + let _ = true >= false; + let _ = true < false; + let _ = true >= false; +} diff --git a/gcc/testsuite/rust/compile/issue-3664.rs b/gcc/testsuite/rust/compile/issue-3664.rs new file mode 100644 index 0000000..c52a758 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3664.rs @@ -0,0 +1,5 @@ +const ARR: [usize; 1] = [2]; + +pub fn l8() { + let _ = 5 << ARR[0]; +} diff --git a/gcc/testsuite/rust/compile/issue-3711.rs b/gcc/testsuite/rust/compile/issue-3711.rs new file mode 100644 index 0000000..a3f9c39 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3711.rs @@ -0,0 +1,17 @@ +#[lang = "sized"] +pub trait Sized {} + +#[lang = "fn_once"] +pub trait FnOnce<Args> { + #[lang = "fn_once_output"] + type Output; + + extern "rust-call" fn call_once(self, args: Args) -> Self::Output; +} + +fn returns_closure() -> _ { + // { dg-error "the type placeholder ._. is not allowed within types on item signatures .E0121." "" { target *-*-* } .-1 } + || 0 +} + +fn main() {} diff --git a/gcc/testsuite/rust/compile/issue-402.rs b/gcc/testsuite/rust/compile/issue-402.rs new file mode 100644 index 0000000..2c99fc8 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-402.rs @@ -0,0 +1,14 @@ +#[lang = "sized"] +pub trait Sized {} + +struct GenericStruct<T>(T, usize); + +pub fn test() -> GenericStruct<_> { + // { dg-error "the type placeholder ._. is not allowed within types on item signatures .E0121." "" { target *-*-* } .-1 } + GenericStruct(1, 2) +} + +fn square(num: i32) -> _ { + // { dg-error "the type placeholder ._. is not allowed within types on item signatures .E0121." "" { target *-*-* } .-1 } + num * num +} diff --git a/gcc/testsuite/rust/compile/macros/mbe/macro-issue2983_2984.rs b/gcc/testsuite/rust/compile/macros/mbe/macro-issue2983_2984.rs index 637d572..eeae6eb 100644 --- a/gcc/testsuite/rust/compile/macros/mbe/macro-issue2983_2984.rs +++ b/gcc/testsuite/rust/compile/macros/mbe/macro-issue2983_2984.rs @@ -18,10 +18,9 @@ fn main() { // Error let _ = ReadDir { + // { dg-error "unknown field .end_of_stream_but_different. .E0560." "" { target *-*-* } .-1 } inner: 14, end_of_stream: false, - end_of_stream_but_different: false, // { dg-error "failed to resolve type for field" } - // { dg-error "unknown field" "" { target *-*-* } .-1 } - // { dg-prune-output "compilation terminated" } + end_of_stream_but_different: false, }; } diff --git a/gcc/testsuite/rust/compile/multiple_bindings1.rs b/gcc/testsuite/rust/compile/multiple_bindings1.rs index e73dc2a..8a2e18c 100644 --- a/gcc/testsuite/rust/compile/multiple_bindings1.rs +++ b/gcc/testsuite/rust/compile/multiple_bindings1.rs @@ -1,29 +1,38 @@ +#[lang = "sized"] +pub trait Sized {} + +#[lang = "fn_once"] +trait FnOnce<Args> { + type Output; + + fn call_once(self, args: Args) -> Self::Output; +} + fn f1(i: i32, i: i32) {} // { dg-error "identifier .i. is bound more than once in the same parameter list .E0415." "" { target *-*-* } .-1 } trait Foo { - fn f2(i: i32, i: i32) {} - // { dg-error "identifier .i. is bound more than once in the same parameter list .E0415." "" { target *-*-* } .-1 } + fn f2(i: i32, i: i32) {} + // { dg-error "identifier .i. is bound more than once in the same parameter list .E0415." "" { target *-*-* } .-1 } } trait Bar { - fn f3(i: i32, j: i32) {} + fn f3(i: i32, j: i32) {} } struct S; impl S { - fn f4(i: i32, i: i32) {} - // { dg-error "identifier .i. is bound more than once in the same parameter list .E0415." "" { target *-*-* } .-1 } + fn f4(i: i32, i: i32) {} + // { dg-error "identifier .i. is bound more than once in the same parameter list .E0415." "" { target *-*-* } .-1 } } impl Bar for S { - fn f3(i: i32, i: i32) {} - // { dg-error "identifier .i. is bound more than once in the same parameter list .E0415." "" { target *-*-* } .-1 } + fn f3(i: i32, i: i32) {} + // { dg-error "identifier .i. is bound more than once in the same parameter list .E0415." "" { target *-*-* } .-1 } } fn main() { - let _ = |i, i| {}; - // { dg-error "identifier .i. is bound more than once in the same parameter list .E0415." "" { target *-*-* } .-1 } + let _ = |i, i| {}; + // { dg-error "identifier .i. is bound more than once in the same parameter list .E0415." "" { target *-*-* } .-1 } } - diff --git a/gcc/testsuite/rust/compile/name_resolution9.rs b/gcc/testsuite/rust/compile/name_resolution9.rs index 93adb46..792b3bd 100644 --- a/gcc/testsuite/rust/compile/name_resolution9.rs +++ b/gcc/testsuite/rust/compile/name_resolution9.rs @@ -6,11 +6,11 @@ pub mod foo { super::super::super::foo!(); // { dg-error "too many leading .super. keywords" } // { dg-error "could not resolve macro invocation" "" { target *-*-* } .-1 } - super::crate::foo!(); // { dg-error "leading path segment .crate. can only be used" } + super::crate::foo!(); // { dg-error ".crate. in paths can only be used" } // { dg-error "could not resolve macro invocation" "" { target *-*-* } .-1 } - crate::foo::bar::super::foo!(); // { dg-error "leading path segment .super. can only be used" } + crate::foo::bar::super::foo!(); // { dg-error ".super. in paths can only be used" } // { dg-error "could not resolve macro invocation" "" { target *-*-* } .-1 } } } diff --git a/gcc/testsuite/rust/compile/nonexistent-field.rs b/gcc/testsuite/rust/compile/nonexistent-field.rs index e20c49d..9bcfb2f 100644 --- a/gcc/testsuite/rust/compile/nonexistent-field.rs +++ b/gcc/testsuite/rust/compile/nonexistent-field.rs @@ -6,7 +6,7 @@ fn main() { let s = StructWithFields { x: 0 }; s.foo; - // { dg-error "no field .foo. on type .StructWithFields.StructWithFields .x.u32... .E0609." "" { target *-*-* } .-1 } + // { dg-error "no field .foo. on type .StructWithFields. .E0609." "" { target *-*-* } .-1 } let numbers = (1, 2, 3); numbers.3; diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index 4772517..c020e36 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -1,25 +1,17 @@ canonical_paths1.rs -cfg1.rs -generics9.rs issue-3315-2.rs -lookup_err1.rs -multiple_bindings1.rs -multiple_bindings2.rs privacy5.rs privacy8.rs pub_restricted_1.rs pub_restricted_2.rs pub_restricted_3.rs -use_1.rs issue-2905-2.rs -derive_clone_enum3.rs -derive-debug1.rs derive-default1.rs derive-eq-invalid.rs -derive-hash1.rs torture/alt_patterns1.rs torture/name_resolve1.rs -issue-3568.rs issue-3663.rs issue-3671.rs +issue-3652.rs +issue-3649.rs # please don't delete the trailing newline diff --git a/gcc/testsuite/rust/compile/self-path2.rs b/gcc/testsuite/rust/compile/self-path2.rs index 6441c33..d955ed0 100644 --- a/gcc/testsuite/rust/compile/self-path2.rs +++ b/gcc/testsuite/rust/compile/self-path2.rs @@ -11,11 +11,11 @@ fn baz() { crate::bar(); crate::self::foo(); - // { dg-error "leading path segment .self. can only be used at the beginning of a path" "" { target *-*-* } .-1 } + // { dg-error ".self. in paths can only be used in start position" "" { target *-*-* } .-1 } } type a = foo; type b = crate::foo; type c = self::foo; type d = crate::self::foo; -// { dg-error "leading path segment .self. can only be used at the beginning of a path" "" { target *-*-* } .-1 } +// { dg-error ".self. in paths can only be used in start position" "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/rust/compile/struct_init1.rs b/gcc/testsuite/rust/compile/struct_init1.rs index 1875fb4..38f6f38 100644 --- a/gcc/testsuite/rust/compile/struct_init1.rs +++ b/gcc/testsuite/rust/compile/struct_init1.rs @@ -4,7 +4,7 @@ struct Foo { } fn main() { - let a = Foo { 0: 10.0, 1: 20.0 }; // { dg-error "failed to resolve type for field" } - // { dg-error "unknown field" "" { target *-*-* } .-1 } - // { dg-prune-output "compilation terminated" } + let a = Foo { 0: 10.0, 1: 20.0 }; + // { dg-error "unknown field .0. .E0560." "" { target *-*-* } .-1 } + // { dg-error "unknown field .1. .E0560." "" { target *-*-* } .-2 } } diff --git a/gcc/testsuite/rust/compile/use_1.rs b/gcc/testsuite/rust/compile/use_1.rs index 94b9632..e8e2037 100644 --- a/gcc/testsuite/rust/compile/use_1.rs +++ b/gcc/testsuite/rust/compile/use_1.rs @@ -1,7 +1,8 @@ +// { dg-additional-options "-frust-name-resolution-2.0" } mod frob {} -use foo::bar::baz; // { dg-error "cannot find simple path segment .foo." } -use frob::ulator; // { dg-error "cannot find simple path segment .ulator." } +use foo::bar::baz; // { dg-error "unresolved import .foo::bar::baz." } +use frob::ulator; // { dg-error "unresolved import .frob::ulator." } mod sain { mod doux {} @@ -9,8 +10,8 @@ mod sain { mod dron {} } -use not_sain::*; // { dg-error "cannot find simple path segment .not_sain." } +use not_sain::*; // { dg-error "unresolved import .not_sain." } use sain::*; use sain::{doux, dron}; -use sain::{doux, dron, graal}; // { dg-error "cannot find simple path segment .graal." } +use sain::{doux, dron, graal}; // { dg-error "unresolved import .sain::graal." } |