Add LayoutSizeOverflow

This commit is contained in:
Ellis Hoag 2022-08-27 15:19:16 -07:00
parent 33b58ebf22
commit 534ce39aac
2 changed files with 11 additions and 2 deletions

View File

@ -18,6 +18,7 @@
use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
use crate::callee::get_fn;
use crate::errors::LayoutSizeOverflow;
#[derive(Clone)]
pub struct FuncSig<'gcc> {
@ -477,7 +478,7 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
#[inline]
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
if let LayoutError::SizeOverflow(_) = err {
self.sess().span_fatal(span, &err.to_string())
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
} else {
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
}
@ -495,7 +496,7 @@ fn handle_fn_abi_err(
fn_abi_request: FnAbiRequest<'tcx>,
) -> ! {
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
self.sess().span_fatal(span, &err.to_string())
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
} else {
match fn_abi_request {
FnAbiRequest::OfFnPtr { sig, extra_args } => {

View File

@ -7,6 +7,14 @@ pub(crate) struct RanlibFailure {
pub exit_code: Option<i32>
}
#[derive(SessionDiagnostic)]
#[diag(codegen_gcc::layout_size_overflow)]
pub(crate) struct LayoutSizeOverflow {
#[primary_span]
pub span: Span,
pub error: String,
}
#[derive(SessionDiagnostic)]
#[diag(codegen_gcc::linkage_const_or_mut_type)]
pub(crate) struct LinkageConstOrMutType {