Port InvalidMinimumAlignment

This commit is contained in:
SLASHLogin 2022-08-26 10:30:43 +02:00
parent 39d363fd58
commit 5d79d3c4bb
3 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,7 @@
use crate::base;
use crate::common::{self, CodegenCx};
use crate::debuginfo;
use crate::errors::InvalidMinimumAlignment;
use crate::llvm::{self, True};
use crate::llvm_util;
use crate::type_::Type;
@ -146,7 +147,9 @@ fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align:
match Align::from_bits(min) {
Ok(min) => align = align.max(min),
Err(err) => {
cx.sess().err(&format!("invalid minimum global alignment: {}", err));
cx.sess().emit_err(InvalidMinimumAlignment {
err,
});
}
}
}

View File

@ -67,3 +67,9 @@ pub(crate) struct LayoutSizeOverflow {
pub span: Span,
pub error: String,
}
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::invalid_minimum_alignment)]
pub(crate) struct InvalidMinimumAlignment {
pub err: String
}

View File

@ -27,3 +27,6 @@ codegen_llvm_branch_protection_requires_aarch64 =
codegen_llvm_layout_size_overflow =
{$error}
codegen_llvm_invalid_minimum_alignment =
invalid minimum global alignment: {$err}