1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc // For a reference to a complete type, output the dereferenceable attribute (in
4*0a6a1f1dSLionel Sambuc // any address space).
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuc typedef int a __attribute__((address_space(1)));
7*0a6a1f1dSLionel Sambuc
foo(a & x,a & y)8*0a6a1f1dSLionel Sambuc a & foo(a &x, a & y) {
9*0a6a1f1dSLionel Sambuc return x;
10*0a6a1f1dSLionel Sambuc }
11*0a6a1f1dSLionel Sambuc
12*0a6a1f1dSLionel Sambuc // CHECK: define dereferenceable(4) i32 addrspace(1)* @_Z3fooRU3AS1iS0_(i32 addrspace(1)* dereferenceable(4) %x, i32 addrspace(1)* dereferenceable(4) %y)
13*0a6a1f1dSLionel Sambuc
14*0a6a1f1dSLionel Sambuc // For a reference to an incomplete type in an alternate address space, output
15*0a6a1f1dSLionel Sambuc // neither dereferenceable nor nonnull.
16*0a6a1f1dSLionel Sambuc
17*0a6a1f1dSLionel Sambuc class bc;
18*0a6a1f1dSLionel Sambuc typedef bc b __attribute__((address_space(1)));
19*0a6a1f1dSLionel Sambuc
bar(b & x,b & y)20*0a6a1f1dSLionel Sambuc b & bar(b &x, b & y) {
21*0a6a1f1dSLionel Sambuc return x;
22*0a6a1f1dSLionel Sambuc }
23*0a6a1f1dSLionel Sambuc
24*0a6a1f1dSLionel Sambuc // CHECK: define %class.bc addrspace(1)* @_Z3barRU3AS12bcS1_(%class.bc addrspace(1)* %x, %class.bc addrspace(1)* %y)
25*0a6a1f1dSLionel Sambuc
26*0a6a1f1dSLionel Sambuc // For a reference to an incomplete type in addrspace(0), output nonnull.
27*0a6a1f1dSLionel Sambuc
bar2(bc & x,bc & y)28*0a6a1f1dSLionel Sambuc bc & bar2(bc &x, bc & y) {
29*0a6a1f1dSLionel Sambuc return x;
30*0a6a1f1dSLionel Sambuc }
31*0a6a1f1dSLionel Sambuc
32*0a6a1f1dSLionel Sambuc // CHECK: define nonnull %class.bc* @_Z4bar2R2bcS0_(%class.bc* nonnull %x, %class.bc* nonnull %y)
33*0a6a1f1dSLionel Sambuc
34*0a6a1f1dSLionel Sambuc
35