1// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o %t-64.ll
2// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.ll %s
3// rdar: // 8390455
4
5@class NSArray;
6
7static  NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
8
9  for(id rawAddress in addresses)
10  {
11   NSArray *separatedAddresses = ((NSArray*)0);
12   separatedAddresses = ArrayRecurs((NSArray *)rawAddress, level+1);
13  }
14  return (NSArray *)0;
15};
16
17extern NSArray *address;
18extern unsigned long level;
19
20void FUNC()
21{
22 ArrayRecurs(address, level);
23
24 static  NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
25
26  for(id rawAddress in addresses)
27  {
28   NSArray *separatedAddresses = ((NSArray*)0);
29   separatedAddresses = ArrayRecurs((NSArray *)rawAddress, level+1);
30  }
31  return (NSArray *)0;
32 };
33 ArrayRecurs(address, level);
34
35 if (ArrayRecurs) {
36   static  NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
37
38     for(id rawAddress in addresses)
39     {
40       NSArray *separatedAddresses = ((NSArray*)0);
41       separatedAddresses = ArrayRecurs((NSArray *)rawAddress, level+1);
42     }
43     return (NSArray *)0;
44   };
45   ArrayRecurs(address, level);
46 }
47}
48
49void FUNC1()
50{
51 static  NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
52
53  for(id rawAddress in addresses)
54  {
55   NSArray *separatedAddresses = ((NSArray*)0);
56   separatedAddresses = ArrayRecurs((NSArray *)rawAddress, level+1);
57  }
58  return (NSArray *)0;
59 };
60 ArrayRecurs(address, level);
61}
62// CHECK-LP64: @ArrayRecurs = internal global
63// CHECK-LP64: @FUNC.ArrayRecurs = internal global
64// CHECK-LP64: @FUNC.ArrayRecurs.1 = internal global
65// CHECK-LP64: @FUNC1.ArrayRecurs = internal global
66