Home | History | Annotate | Download | only in CodeGenCXX
      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 {
      7  Foo() : iFoo (2) {
      8   printf("%p\n", this);
      9  }
     10  int iFoo;
     11 };
     12 
     13 
     14 typedef Foo (*T)[3][4];
     15 
     16 T bar() {
     17  return new Foo[2][3][4];
     18 }
     19 
     20 T bug(int i) {
     21   return new Foo[i][3][4];
     22 }
     23 
     24 void 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 
     30 Foo *test() {
     31   return new Foo[5];
     32 }
     33 
     34 int 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 noalias i8* @_Znam
     47 // CHECK: call noalias i8* @_Znam
     48 // CHECK: call noalias i8* @_Znam
     49 
     50