blob: f348b2b6fda6ac4826b4a72dd807b8f13f8b2461 [file] [log] [blame]
NAKAMURA Takumia7246da2013-01-22 01:51:59 +00001// RUN: %clang_cc1 -triple i386-unknown-unknown -O1 -emit-llvm -o - %s | FileCheck %s
Stephen Lin93ab6bf2013-08-15 06:47:53 +00002// CHECK-LABEL: define i32 @f0
NAKAMURA Takumia7246da2013-01-22 01:51:59 +00003// CHECK: ret i32 1
Stephen Lin93ab6bf2013-08-15 06:47:53 +00004// CHECK-LABEL: define i32 @f1
NAKAMURA Takumia7246da2013-01-22 01:51:59 +00005// CHECK: ret i32 1
Stephen Lin93ab6bf2013-08-15 06:47:53 +00006// CHECK-LABEL: define i32 @f2
NAKAMURA Takumia7246da2013-01-22 01:51:59 +00007// CHECK: ret i32 1
Daniel Dunbar8c6f57c2008-08-06 02:00:38 +00008// <rdr://6115726>
9
10int f0() {
11 int x;
12 unsigned short n = 1;
13 int *a = &x;
14 int *b = &x;
15 a = a - n;
16 b -= n;
17 return a == b;
18}
19
20int f1(int *a) {
Sebastian Redlf0d960a2008-11-12 00:18:32 +000021 long b = a - (int*) 1;
Daniel Dunbar8c6f57c2008-08-06 02:00:38 +000022 a -= (int*) 1;
Sebastian Redlf0d960a2008-11-12 00:18:32 +000023 return b == (long) a;
Daniel Dunbar8c6f57c2008-08-06 02:00:38 +000024}
25
Sebastian Redlf0d960a2008-11-12 00:18:32 +000026int f2(long n) {
Daniel Dunbar8c6f57c2008-08-06 02:00:38 +000027 int *b = n + (int*) 1;
28 n += (int*) 1;
29 return b == (int*) n;
30}
31