Skip to content

Commit

Permalink
librustc_codegen_llvm: Use repr(transparent) for bitflags over repr(C) (
Browse files Browse the repository at this point in the history
#61306)

In order to make sure that Rust's bitflags types are passed the same
way in the Rust ABI as they are in the C ABI, we need to use the attribute
repr(transparent) over the repr(C) attribute for the single-field bitflags
structs in in order to prevent ABI mismatches. Thanks to Michael Karcher
for finding this bug.
  • Loading branch information
glaubitz committed Jun 16, 2019
1 parent 0dc9e9c commit 3fa7411
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/llvm/ffi.rs
Expand Up @@ -564,7 +564,7 @@ pub mod debuginfo {

// These values **must** match with LLVMRustDIFlags!!
bitflags! {
#[repr(C)]
#[repr(transparent)]
#[derive(Default)]
pub struct DIFlags: ::libc::uint32_t {
const FlagZero = 0;
Expand Down Expand Up @@ -593,7 +593,7 @@ pub mod debuginfo {

// These values **must** match with LLVMRustDISPFlags!!
bitflags! {
#[repr(C)]
#[repr(transparent)]
#[derive(Default)]
pub struct DISPFlags: ::libc::uint32_t {
const SPFlagZero = 0;
Expand Down

0 comments on commit 3fa7411

Please sign in to comment.