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