Skip to content

Commit

Permalink
Harden tests for repr_align_enum.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed May 27, 2019
1 parent de1e1ad commit c25e3d2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
19 changes: 14 additions & 5 deletions src/test/ui/repr/repr-align.rs
Original file line number Diff line number Diff line change
@@ -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() {}
16 changes: 14 additions & 2 deletions src/test/ui/repr/repr-align.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

0 comments on commit c25e3d2

Please sign in to comment.