aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c
blob: 429fb1fcc27b7c8afee17b7e5c28a4dc67b3e737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// RUN: %clang_cc1 -triple i386-unknown-unknown -O1 -emit-llvm -o - %s | FileCheck %s
// CHECK: define i32 @f0
// CHECK:   ret i32 1
// CHECK: define i32 @f1
// CHECK:   ret i32 1
// CHECK: define i32 @f2
// CHECK:   ret i32 1
// <rdr://6115726>

int f0() {
  int x;
  unsigned short n = 1;
  int *a = &x;
  int *b = &x;
  a = a - n;
  b -= n;
  return a == b;
}

int f1(int *a) {
  long b = a - (int*) 1;
  a -= (int*) 1;
  return b == (long) a;
}

int f2(long n) {
  int *b = n + (int*) 1;
  n += (int*) 1;
  return b == (int*) n;
}