about summary refs log tree commit diff
diff options
context:
space:
mode:
authorantoyo <antoyo@users.noreply.github.com>2023-09-20 17:57:04 -0400
committerGitHub <noreply@github.com>2023-09-20 17:57:04 -0400
commite7d1dc33c6ddeb44e341672748b649b07f09a7ba (patch)
treed8628ba4d378731afa03deb0c74831d4a0d200ea
parent6118ee488a4bbf22e8a40251c9d7612770c5e81b (diff)
parentbe3b1e33215bec2d47bcb0455c9b27d412b9328a (diff)
downloadrust-e7d1dc33c6ddeb44e341672748b649b07f09a7ba.tar.gz
rust-e7d1dc33c6ddeb44e341672748b649b07f09a7ba.zip
Merge pull request #337 from rust-lang/fix/gep
Fix gep on pointers to non-number
-rw-r--r--Cargo.lock4
-rw-r--r--failing-ui-tests.txt1
-rw-r--r--failing-ui-tests12.txt1
-rw-r--r--src/builder.rs6
-rw-r--r--src/gcc_util.rs16
-rwxr-xr-xtest.sh1
-rw-r--r--tests/run/gep.rs10
7 files changed, 31 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 404fb9c6db1..85675fc40c3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -74,7 +74,7 @@ dependencies = [
 [[package]]
 name = "gccjit"
 version = "1.0.0"
-source = "git+https://github.com/antoyo/gccjit.rs#ff1f82584c760a8b870dc6bad9841bd090f92f80"
+source = "git+https://github.com/antoyo/gccjit.rs#0b158c68bf7e46732869d90550a98e886dee8858"
 dependencies = [
  "gccjit_sys",
 ]
@@ -82,7 +82,7 @@ dependencies = [
 [[package]]
 name = "gccjit_sys"
 version = "0.0.1"
-source = "git+https://github.com/antoyo/gccjit.rs#ff1f82584c760a8b870dc6bad9841bd090f92f80"
+source = "git+https://github.com/antoyo/gccjit.rs#0b158c68bf7e46732869d90550a98e886dee8858"
 dependencies = [
  "libc",
 ]
diff --git a/failing-ui-tests.txt b/failing-ui-tests.txt
index 0711ae99a3e..8ec151f7838 100644
--- a/failing-ui-tests.txt
+++ b/failing-ui-tests.txt
@@ -14,7 +14,6 @@ tests/ui/sepcomp/sepcomp-fns-backwards.rs
 tests/ui/sepcomp/sepcomp-fns.rs
 tests/ui/sepcomp/sepcomp-statics.rs
 tests/ui/simd/intrinsic/generic-arithmetic-pass.rs
-tests/ui/target-feature/missing-plusminus.rs
 tests/ui/asm/x86_64/may_unwind.rs
 tests/ui/backtrace.rs
 tests/ui/catch-unwind-bang.rs
diff --git a/failing-ui-tests12.txt b/failing-ui-tests12.txt
index 8c27bd8b8ca..0ac0a034af4 100644
--- a/failing-ui-tests12.txt
+++ b/failing-ui-tests12.txt
@@ -37,3 +37,4 @@ tests/ui/simd/intrinsic/generic-gather-pass.rs
 tests/ui/simd/issue-85915-simd-ptrs.rs
 tests/ui/issues/issue-68010-large-zst-consts.rs
 tests/ui/rust-2018/proc-macro-crate-in-paths.rs
+tests/ui/target-feature/missing-plusminus.rs
diff --git a/src/builder.rs b/src/builder.rs
index b0feb99e3c6..04100f2ad2e 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -922,6 +922,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
         // require dereferencing the pointer.
         for index in indices {
             pointee_type = pointee_type.get_pointee().expect("pointee type");
+            #[cfg(feature="master")]
+            let pointee_size = {
+                let size = self.cx.context.new_sizeof(pointee_type);
+                self.context.new_cast(None, size, index.get_type())
+            };
+            #[cfg(not(feature="master"))]
             let pointee_size = self.context.new_rvalue_from_int(index.get_type(), pointee_type.get_size() as i32);
             result = result + self.gcc_int_cast(*index * pointee_size, self.sizet_type);
         }
diff --git a/src/gcc_util.rs b/src/gcc_util.rs
index 18343d58c35..0514c9988e0 100644
--- a/src/gcc_util.rs
+++ b/src/gcc_util.rs
@@ -1,3 +1,4 @@
+#[cfg(feature="master")]
 use gccjit::Context;
 use smallvec::{smallvec, SmallVec};
 
@@ -202,11 +203,16 @@ fn handle_native(name: &str) -> &str {
         return name;
     }
 
-    // Get the native arch.
-    let context = Context::default();
-    context.get_target_info().arch().unwrap()
-        .to_str()
-        .unwrap()
+    #[cfg(feature="master")]
+    {
+        // Get the native arch.
+        let context = Context::default();
+        context.get_target_info().arch().unwrap()
+            .to_str()
+            .unwrap()
+    }
+    #[cfg(not(feature="master"))]
+    unimplemented!();
 }
 
 pub fn target_cpu(sess: &Session) -> &str {
diff --git a/test.sh b/test.sh
index c47cf140ae4..5b7ef7ab101 100755
--- a/test.sh
+++ b/test.sh
@@ -220,6 +220,7 @@ changelog-seen = 2
 [rust]
 codegen-backends = []
 deny-warnings = false
+verbose-tests = true
 
 [build]
 cargo = "$(rustup which cargo)"
diff --git a/tests/run/gep.rs b/tests/run/gep.rs
new file mode 100644
index 00000000000..c3d1672cff5
--- /dev/null
+++ b/tests/run/gep.rs
@@ -0,0 +1,10 @@
+// Compiler:
+//
+// Run-time:
+//   status: 0
+
+fn main() {
+    let mut value = (1, 1);
+    let ptr = &mut value as *mut (i32, i32);
+    println!("{:?}", ptr.wrapping_offset(10));
+}