diff options
author | CohenArthur <arthur.cohen@epita.fr> | 2021-08-21 17:41:28 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@epita.fr> | 2021-09-09 13:44:44 +0200 |
commit | 5a6341a623919e747ca1c093a85c0aedb0344fd9 (patch) | |
tree | d42900499d2400f7ab9f24916d7c68ce8f32ceff /gcc | |
parent | 6aff3e33a03eaef2ff0d0a89def25abdf36c5b5f (diff) | |
download | gcc-5a6341a623919e747ca1c093a85c0aedb0344fd9.zip gcc-5a6341a623919e747ca1c093a85c0aedb0344fd9.tar.gz gcc-5a6341a623919e747ca1c093a85c0aedb0344fd9.tar.bz2 |
module: Add two test cases for external modules
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/rust/compile/extern_mod2.rs | 14 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/extern_mod1.rs | 6 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/extern_mod2.rs | 16 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/extern_mod4.rs | 17 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/modules/mod.rs | 3 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/modules/valid_path.rs (renamed from gcc/testsuite/rust/compile/modules/valid_path.rs) | 0 |
6 files changed, 42 insertions, 14 deletions
diff --git a/gcc/testsuite/rust/compile/extern_mod2.rs b/gcc/testsuite/rust/compile/extern_mod2.rs deleted file mode 100644 index 67c8a13..0000000 --- a/gcc/testsuite/rust/compile/extern_mod2.rs +++ /dev/null @@ -1,14 +0,0 @@ -#[path = "modules/valid_path.rs"] -mod not_a_valid_path; - -#[path] // { dg-error "path attributes must contain a filename" } -mod error; // { dg-error "no candidate found for module error" } - -// This is "valid", and should only error out when parsing -// the file -// FIXME: Add a dg-error directive on the `mod another_error` line once module expansion -// is added -#[path = "not_a_valid_file.rs"] -mod another_error; - -fn main() {} diff --git a/gcc/testsuite/rust/compile/torture/extern_mod1.rs b/gcc/testsuite/rust/compile/torture/extern_mod1.rs new file mode 100644 index 0000000..4b576e0 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/extern_mod1.rs @@ -0,0 +1,6 @@ +// { dg-additional-options "-w" } +mod modules; + +fn main() { + let twelve = modules::return_12(); +} diff --git a/gcc/testsuite/rust/compile/torture/extern_mod2.rs b/gcc/testsuite/rust/compile/torture/extern_mod2.rs new file mode 100644 index 0000000..f3379e3 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/extern_mod2.rs @@ -0,0 +1,16 @@ +// { dg-additional-options "-w" } + +#[path = "modules/valid_path.rs"] +mod not_a_valid_path; + +// #[path] +// FIXME: This is wrong +// mod error; + +// This is "valid", and should only error out when parsing +// the file +// FIXME: Fix path attribute expanding +// #[path = "not_a_valid_file.rs"] +// mod another_error; + +fn main() {} diff --git a/gcc/testsuite/rust/compile/torture/extern_mod4.rs b/gcc/testsuite/rust/compile/torture/extern_mod4.rs new file mode 100644 index 0000000..80d8497 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/extern_mod4.rs @@ -0,0 +1,17 @@ +// { dg-additional-options "-w" } +// { dg-output "12" } +mod modules; + +extern "C" { + fn printf(s: *const i8, ...); +} + +fn main() { + unsafe { + let fmt_s = "%d\n\0"; + let fmt_p = fmt_s as *const str; + let fmt_i8 = fmt_p as *const i8; + + printf(fmt_i8, modules::return_12()); + } +} diff --git a/gcc/testsuite/rust/compile/torture/modules/mod.rs b/gcc/testsuite/rust/compile/torture/modules/mod.rs new file mode 100644 index 0000000..3d65176 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/modules/mod.rs @@ -0,0 +1,3 @@ +pub fn return_12() -> i32 { + 12 +} diff --git a/gcc/testsuite/rust/compile/modules/valid_path.rs b/gcc/testsuite/rust/compile/torture/modules/valid_path.rs index 6a1519c..6a1519c 100644 --- a/gcc/testsuite/rust/compile/modules/valid_path.rs +++ b/gcc/testsuite/rust/compile/torture/modules/valid_path.rs |