[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / nullptr.cpp
blobca76c55e2122d10ddb3ae1c14eed107be8d94064
1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -I%S -emit-llvm -o - %s | FileCheck %s
3 #include <typeinfo>
5 // CHECK: @_ZTIDn = external constant ptr
6 int* a = nullptr;
8 void f() {
9 int* a = nullptr;
12 typedef decltype(nullptr) nullptr_t;
14 nullptr_t get_nullptr();
16 struct X { };
17 void g() {
18 // CHECK: call ptr @_Z11get_nullptrv()
19 int (X::*pmf)(int) = get_nullptr();
22 const std::type_info& f2() {
23 return typeid(nullptr_t);
26 union U {
27 int n;
28 nullptr_t b;
30 // CHECK-LABEL: define {{.*}}pr23833_a
31 // CHECK: store
32 // CHECK: load
33 // CHECK-NOT: load
34 // CHECK: ret i1 false
35 bool pr23833_a(U &u) { return bool(u.b); }
37 // CHECK-LABEL: define {{.*}}pr23833_b
38 // CHECK: store
39 // CHECK: load
40 // CHECK-NOT: load
41 // CHECK: ret ptr null
42 nullptr_t pr23833_b(nullptr_t &n) { return n; }
44 struct X1 { operator int*(); };
45 struct X2 { operator const nullptr_t&(); };
47 // CHECK-LABEL: define {{.*}}pr23833_c
48 // CHECK: call {{.*}}X1
49 // CHECK: call {{.*}}X2
50 // CHECK-NOT: load
51 // CHECK: ret i32
52 int pr23833_c() {
53 return X1() != X2();
56 // CHECK-LABEL: define {{.*}}pr23833_d
57 // CHECK: call {{.*}}X2
58 // CHECK-NOT: load
59 // CHECK: store
60 // CHECK: load
61 // CHECK: ret ptr
62 int *pr23833_d() {
63 int *p = X2();
64 return p;
67 namespace PR39528 {
68 constexpr nullptr_t null = nullptr;
69 void f(nullptr_t);
70 void g() { f(null); }