diff options
| author | asquared31415 <34665709+asquared31415@users.noreply.github.com> | 2024-10-12 05:37:56 +0000 |
|---|---|---|
| committer | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2024-10-28 13:17:37 +0800 |
| commit | 6fc7ce43d2f2cd2fef1b75c9c59f13f312e0d9d8 (patch) | |
| tree | 16c43b928958e16e940c5efd3682962f5d0848dd /tests | |
| parent | df4ca44d3fbc9301ee17f30f4d474e6ae4b05252 (diff) | |
| download | rust-6fc7ce43d2f2cd2fef1b75c9c59f13f312e0d9d8.tar.gz rust-6fc7ce43d2f2cd2fef1b75c9c59f13f312e0d9d8.zip | |
Error on alignments greater than `isize::MAX`
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/repr/repr_align_greater_usize.msp430.stderr | 19 | ||||
| -rw-r--r-- | tests/ui/repr/repr_align_greater_usize.rs | 25 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/ui/repr/repr_align_greater_usize.msp430.stderr b/tests/ui/repr/repr_align_greater_usize.msp430.stderr new file mode 100644 index 00000000000..7c85249c009 --- /dev/null +++ b/tests/ui/repr/repr_align_greater_usize.msp430.stderr @@ -0,0 +1,19 @@ +error[E0589]: alignment must not be greater than `isize::MAX` bytes + --> $DIR/repr_align_greater_usize.rs:21:8 + | +LL | #[repr(align(32768))] + | ^^^^^^^^^^^^ + | + = note: `isize::MAX` is 32767 for the current target + +error[E0589]: alignment must not be greater than `isize::MAX` bytes + --> $DIR/repr_align_greater_usize.rs:24:8 + | +LL | #[repr(align(65536))] + | ^^^^^^^^^^^^ + | + = note: `isize::MAX` is 32767 for the current target + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0589`. diff --git a/tests/ui/repr/repr_align_greater_usize.rs b/tests/ui/repr/repr_align_greater_usize.rs new file mode 100644 index 00000000000..b47320b6d9b --- /dev/null +++ b/tests/ui/repr/repr_align_greater_usize.rs @@ -0,0 +1,25 @@ +//@ revisions: msp430 aarch32 +//@[msp430] needs-llvm-components: msp430 +//@[msp430] compile-flags: --target=msp430-none-elf +//@[aarch32] build-pass +//@[aarch32] needs-llvm-components: arm +//@[aarch32] compile-flags: --target=thumbv7m-none-eabi + +// We should fail to compute alignment for types aligned higher than usize::MAX. +// We can't handle alignments that require all 32 bits, so this only affects 16-bit. + +#![feature(lang_items, no_core)] +#![no_core] +#![crate_type = "lib"] + +#[lang = "sized"] +trait Sized {} + +#[repr(align(16384))] +struct Kitten; + +#[repr(align(32768))] //[msp430]~ ERROR alignment must not be greater than `isize::MAX` +struct Cat; + +#[repr(align(65536))] //[msp430]~ ERROR alignment must not be greater than `isize::MAX` +struct BigCat; |
