blob: e809effb2b10086b8327e59937c7ca4e0d2be3d5 [file] [log] [blame]
Cameron Esfahani1484e0d2010-09-15 00:28:12 +00001// RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm -O2 -o - %s | FileCheck %s
2
3// Under Windows 64, int and long are 32-bits. Make sure pointer math doesn't
4// cause any sign extensions.
5
Cameron Esfahaniee0f9842010-09-15 10:52:02 +00006// CHECK: [[P:%.*]] = add i64 %param, -8
Benjamin Kramerbf3a60b2010-09-15 12:31:46 +00007// CHECK-NEXT: [[Q:%.*]] = inttoptr i64 [[P]] to [[R:%.*\*]]
Cameron Esfahaniee0f9842010-09-15 10:52:02 +00008// CHECK-NEXT: {{%.*}} = getelementptr inbounds [[R]] [[Q]], i64 0, i32 0
Cameron Esfahani1484e0d2010-09-15 00:28:12 +00009
10#define CR(Record, TYPE, Field) \
11 ((TYPE *) ((unsigned char *) (Record) - (unsigned char *) &(((TYPE *) 0)->Field)))
12
13typedef struct _LIST_ENTRY {
14 struct _LIST_ENTRY *ForwardLink;
15 struct _LIST_ENTRY *BackLink;
16} LIST_ENTRY;
17
18typedef struct {
19 unsigned long long Signature;
20 LIST_ENTRY Link;
21} MEMORY_MAP;
22
23int test(unsigned long long param)
24{
25 LIST_ENTRY *Link;
26 MEMORY_MAP *Entry;
27
28 Link = (LIST_ENTRY *) param;
29
30 Entry = CR (Link, MEMORY_MAP, Link);
31 return (int) Entry->Signature;
32}