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