multi-dim-operator-new.cpp revision 4967a710c84587c654b56c828382219c3937dacb
1// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s 2// PR6641 3 4extern "C" int printf(const char *, ...); 5 6struct Foo { 7 Foo() : iFoo (2) { 8 printf("%p\n", this); 9 } 10 int iFoo; 11}; 12 13 14typedef Foo (*T)[3][4]; 15 16T bar() { 17 return new Foo[2][3][4]; 18} 19 20T bug(int i) { 21 return new Foo[i][3][4]; 22} 23 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 30Foo *test() { 31 return new Foo[5]; 32} 33 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