1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -emit-llvm -o - 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // This tests all kinds of hard cases with initializers and 4*f4a2713aSLionel Sambuc // array subscripts. This corresponds to PR487. 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc struct X { int a[2]; }; 7*f4a2713aSLionel Sambuc test()8*f4a2713aSLionel Sambucint test() { 9*f4a2713aSLionel Sambuc static int i23 = (int) &(((struct X *)0)->a[1]); 10*f4a2713aSLionel Sambuc return i23; 11*f4a2713aSLionel Sambuc } 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc int i = (int) &( ((struct X *)0) -> a[1]); 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc int Arr[100]; 16*f4a2713aSLionel Sambuc foo(int i)17*f4a2713aSLionel Sambucint foo(int i) { return bar(&Arr[49])+bar(&Arr[i]); } foo2(int i)18*f4a2713aSLionel Sambucint foo2(int i) { 19*f4a2713aSLionel Sambuc static const int *X = &Arr[49]; 20*f4a2713aSLionel Sambuc static int i23 = (int) &( ((struct X *)0) -> a[0]); 21*f4a2713aSLionel Sambuc int *P = Arr; 22*f4a2713aSLionel Sambuc ++P; 23*f4a2713aSLionel Sambuc return bar(Arr+i); 24*f4a2713aSLionel Sambuc } 25