1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s 2*f4a2713aSLionel Sambuc // PR6641 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc extern "C" int printf(const char *, ...); 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc struct Foo { FooFoo7*f4a2713aSLionel Sambuc Foo() : iFoo (2) { 8*f4a2713aSLionel Sambuc printf("%p\n", this); 9*f4a2713aSLionel Sambuc } 10*f4a2713aSLionel Sambuc int iFoo; 11*f4a2713aSLionel Sambuc }; 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc typedef Foo (*T)[3][4]; 15*f4a2713aSLionel Sambuc bar()16*f4a2713aSLionel SambucT bar() { 17*f4a2713aSLionel Sambuc return new Foo[2][3][4]; 18*f4a2713aSLionel Sambuc } 19*f4a2713aSLionel Sambuc bug(int i)20*f4a2713aSLionel SambucT bug(int i) { 21*f4a2713aSLionel Sambuc return new Foo[i][3][4]; 22*f4a2713aSLionel Sambuc } 23*f4a2713aSLionel Sambuc pr(T a)24*f4a2713aSLionel Sambucvoid pr(T a) { 25*f4a2713aSLionel Sambuc for (int i = 0; i < 3; i++) 26*f4a2713aSLionel Sambuc for (int j = 0; j < 4; j++) 27*f4a2713aSLionel Sambuc printf("%p\n", a[i][j]); 28*f4a2713aSLionel Sambuc } 29*f4a2713aSLionel Sambuc test()30*f4a2713aSLionel SambucFoo *test() { 31*f4a2713aSLionel Sambuc return new Foo[5]; 32*f4a2713aSLionel Sambuc } 33*f4a2713aSLionel Sambuc main()34*f4a2713aSLionel Sambucint main() { 35*f4a2713aSLionel Sambuc T f = bar(); 36*f4a2713aSLionel Sambuc pr(f); 37*f4a2713aSLionel Sambuc f = bug(3); 38*f4a2713aSLionel Sambuc pr(f); 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc Foo * g = test(); 41*f4a2713aSLionel Sambuc for (int i = 0; i < 5; i++) 42*f4a2713aSLionel Sambuc printf("%d\n", g[i].iFoo); 43*f4a2713aSLionel Sambuc return 0; 44*f4a2713aSLionel Sambuc } 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam 47*f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam 48*f4a2713aSLionel Sambuc // CHECK: call noalias i8* @_Znam 49*f4a2713aSLionel Sambuc 50