Skip to content

Commit be3b1e3

Browse files
committed
Fix gep on pointers to non-number
1 parent f3b82df commit be3b1e3

File tree

7 files changed

+31
-8
lines changed

7 files changed

+31
-8
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

failing-ui-tests.txt

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ tests/ui/sepcomp/sepcomp-fns-backwards.rs
1414
tests/ui/sepcomp/sepcomp-fns.rs
1515
tests/ui/sepcomp/sepcomp-statics.rs
1616
tests/ui/simd/intrinsic/generic-arithmetic-pass.rs
17-
tests/ui/target-feature/missing-plusminus.rs
1817
tests/ui/asm/x86_64/may_unwind.rs
1918
tests/ui/backtrace.rs
2019
tests/ui/catch-unwind-bang.rs

failing-ui-tests12.txt

+1
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ tests/ui/simd/intrinsic/generic-gather-pass.rs
3737
tests/ui/simd/issue-85915-simd-ptrs.rs
3838
tests/ui/issues/issue-68010-large-zst-consts.rs
3939
tests/ui/rust-2018/proc-macro-crate-in-paths.rs
40+
tests/ui/target-feature/missing-plusminus.rs

src/builder.rs

+6
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
922922
// require dereferencing the pointer.
923923
for index in indices {
924924
pointee_type = pointee_type.get_pointee().expect("pointee type");
925+
#[cfg(feature="master")]
926+
let pointee_size = {
927+
let size = self.cx.context.new_sizeof(pointee_type);
928+
self.context.new_cast(None, size, index.get_type())
929+
};
930+
#[cfg(not(feature="master"))]
925931
let pointee_size = self.context.new_rvalue_from_int(index.get_type(), pointee_type.get_size() as i32);
926932
result = result + self.gcc_int_cast(*index * pointee_size, self.sizet_type);
927933
}

src/gcc_util.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg(feature="master")]
12
use gccjit::Context;
23
use smallvec::{smallvec, SmallVec};
34

@@ -202,11 +203,16 @@ fn handle_native(name: &str) -> &str {
202203
return name;
203204
}
204205

205-
// Get the native arch.
206-
let context = Context::default();
207-
context.get_target_info().arch().unwrap()
208-
.to_str()
209-
.unwrap()
206+
#[cfg(feature="master")]
207+
{
208+
// Get the native arch.
209+
let context = Context::default();
210+
context.get_target_info().arch().unwrap()
211+
.to_str()
212+
.unwrap()
213+
}
214+
#[cfg(not(feature="master"))]
215+
unimplemented!();
210216
}
211217

212218
pub fn target_cpu(sess: &Session) -> &str {

test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ changelog-seen = 2
220220
[rust]
221221
codegen-backends = []
222222
deny-warnings = false
223+
verbose-tests = true
223224
224225
[build]
225226
cargo = "$(rustup which cargo)"

tests/run/gep.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Compiler:
2+
//
3+
// Run-time:
4+
// status: 0
5+
6+
fn main() {
7+
let mut value = (1, 1);
8+
let ptr = &mut value as *mut (i32, i32);
9+
println!("{:?}", ptr.wrapping_offset(10));
10+
}

0 commit comments

Comments
 (0)