Add LinkageConstOrMutType
This commit is contained in:
parent
9363f0fda5
commit
7e00a48305
3 changed files with 13 additions and 4 deletions
|
@ -14,6 +14,7 @@ use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRan
|
||||||
|
|
||||||
use crate::base;
|
use crate::base;
|
||||||
use crate::context::CodegenCx;
|
use crate::context::CodegenCx;
|
||||||
|
use crate::errors::LinkageConstOrMutType;
|
||||||
use crate::type_of::LayoutGccExt;
|
use crate::type_of::LayoutGccExt;
|
||||||
|
|
||||||
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
||||||
|
@ -368,10 +369,7 @@ fn check_and_apply_linkage<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, attrs: &Codeg
|
||||||
cx.layout_of(mt.ty).gcc_type(cx, true)
|
cx.layout_of(mt.ty).gcc_type(cx, true)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cx.sess().span_fatal(
|
cx.sess().emit_fatal(LinkageConstOrMutType { span: span })
|
||||||
span,
|
|
||||||
"must have type `*const T` or `*mut T` due to `#[linkage]` attribute",
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
// Declare a symbol `foo` with the desired linkage.
|
// Declare a symbol `foo` with the desired linkage.
|
||||||
let global1 = cx.declare_global_with_linkage(&sym, llty2, base::global_linkage_to_gcc(linkage));
|
let global1 = cx.declare_global_with_linkage(&sym, llty2, base::global_linkage_to_gcc(linkage));
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
use rustc_macros::SessionDiagnostic;
|
use rustc_macros::SessionDiagnostic;
|
||||||
|
use rustc_span::Span;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(codegen_gcc::ranlib_failure)]
|
#[diag(codegen_gcc::ranlib_failure)]
|
||||||
pub(crate) struct RanlibFailure {
|
pub(crate) struct RanlibFailure {
|
||||||
pub exit_code: Option<i32>
|
pub exit_code: Option<i32>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(SessionDiagnostic)]
|
||||||
|
#[diag(codegen_gcc::linkage_const_or_mut_type)]
|
||||||
|
pub(crate) struct LinkageConstOrMutType {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
codegen_gcc_ranlib_failure =
|
codegen_gcc_ranlib_failure =
|
||||||
Ranlib exited with code {$exit_code}
|
Ranlib exited with code {$exit_code}
|
||||||
|
|
||||||
|
codegen_gcc_linkage_const_or_mut_type =
|
||||||
|
must have type `*const T` or `*mut T` due to `#[linkage]` attribute
|
Loading…
Add table
Add a link
Reference in a new issue