Harden tests for repr_align_enum.

This commit is contained in:
Mazdak Farrokhzad 2019-05-27 07:35:48 +02:00
parent de1e1ad706
commit c25e3d2be5
2 changed files with 28 additions and 7 deletions

View file

@ -1,18 +1,27 @@
#![allow(dead_code)]
#[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer
struct A(i32);
struct S0(i32);
#[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two
struct B(i32);
struct S1(i32);
#[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29
struct C(i32);
struct S2(i32);
#[repr(align(536870912))] // ok: this is the largest accepted alignment
struct D(i32);
struct S3(i32);
#[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer
enum E0 { A, B }
#[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two
enum E { Left, Right }
enum E1 { A, B }
#[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29
enum E2 { A, B }
#[repr(align(536870912))] // ok: this is the largest accepted alignment
enum E3 { A, B }
fn main() {}

View file

@ -16,12 +16,24 @@ error[E0589]: invalid `repr(align)` attribute: larger than 2^29
LL | #[repr(align(4294967296))]
| ^^^^^^^^^^^^^^^^^
error[E0589]: invalid `repr(align)` attribute: not a power of two
error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
--> $DIR/repr-align.rs:15:8
|
LL | #[repr(align(16.0))]
| ^^^^^^^^^^^
error[E0589]: invalid `repr(align)` attribute: not a power of two
--> $DIR/repr-align.rs:18:8
|
LL | #[repr(align(15))]
| ^^^^^^^^^
error: aborting due to 4 previous errors
error[E0589]: invalid `repr(align)` attribute: larger than 2^29
--> $DIR/repr-align.rs:21:8
|
LL | #[repr(align(4294967296))]
| ^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0589`.