-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #82379 - nagisa:nagisa/hexagon-enums, r=estebank
Fix sizes of repr(C) enums on hexagon Enums on hexagon use a smallest size (but at least 1 byte) that fits all the enumeration values. This is unlike many other ABIs where enums are at least 32 bits. Fixes #82100
- Loading branch information
Showing
3 changed files
with
476 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// compile-flags: --target hexagon-unknown-linux-musl | ||
// | ||
// Verify that the hexagon targets implement the repr(C) for enums correctly. | ||
// | ||
// See #82100 | ||
#![feature(never_type, rustc_attrs, type_alias_impl_trait, no_core, lang_items)] | ||
#![crate_type = "lib"] | ||
#![no_core] | ||
|
||
#[lang="sized"] | ||
trait Sized {} | ||
|
||
#[rustc_layout(debug)] | ||
#[repr(C)] | ||
enum A { Apple } //~ ERROR: layout_of | ||
|
||
#[rustc_layout(debug)] | ||
#[repr(C)] | ||
enum B { Banana = 255, } //~ ERROR: layout_of | ||
|
||
#[rustc_layout(debug)] | ||
#[repr(C)] | ||
enum C { Chaenomeles = 256, } //~ ERROR: layout_of | ||
|
||
#[rustc_layout(debug)] | ||
#[repr(C)] | ||
enum P { Peach = 0x1000_0000isize, } //~ ERROR: layout_of | ||
|
||
const TANGERINE: usize = 0x8100_0000; // hack to get negative numbers without negation operator! | ||
|
||
#[rustc_layout(debug)] | ||
#[repr(C)] | ||
enum T { Tangerine = TANGERINE as isize } //~ ERROR: layout_of |
Oops, something went wrong.