Skip to content

Commit 2fe674b

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

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

Cargo.lock

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

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 {

0 commit comments

Comments
 (0)