Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/rustc_lint/src/types/improper_ctypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::ops::ControlFlow;

use bitflags::bitflags;
use rustc_abi::VariantIdx;
use rustc_attr_ir::LangItem;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{DiagMessage, msg};
use rustc_hashes::Hash128;
Expand Down Expand Up @@ -802,6 +803,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
}
match def.adt_kind() {
AdtKind::Struct | AdtKind::Union => {
if tcx.is_lang_item(def.did(), LangItem::PpcF128) {
return FfiResult::FfiSafe;
}
if let Some(sym::cstring_type | sym::cstr_type) =
tcx.get_diagnostic_name(def.did())
&& !self.base_ty.is_mutable_ptr()
Expand Down
27 changes: 27 additions & 0 deletions tests/ui/lint/improper-ctypes/ppcf128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#![deny(improper_ctypes_definitions)]
//@ add-minicore
//@ check-pass
//@ revisions: PPC64 PPC64LE PPC32
//@ [PPC32] compile-flags: --target=powerpc-unknown-linux-gnu
//@ [PPC64] compile-flags: --target=powerpc64-unknown-linux-gnu
//@ [PPC64LE] compile-flags: --target=powerpc64le-unknown-linux-gnu
//@ needs-llvm-components: powerpc
#![feature(no_core)]
#![no_core]
#![crate_type = "lib"]

extern crate minicore;

// The ppcf128 type is implemented as an ADT, so it needs custom logic
// to be accepted by improper_ctypes.

#[cfg(target_arch = "powerpc")]
use minicore::arch::powerpc::ppcf128;
#[cfg(target_arch = "powerpc64")]
use minicore::arch::powerpc64::ppcf128;
use minicore::*;

#[unsafe(no_mangle)]
extern "C" fn identity(x: ppcf128) -> ppcf128 {
x
}
Loading