2011-10-14 06:29:44 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -I%S -emit-llvm -o - %s | FileCheck %s
|
2009-09-15 12:39:46 +08:00
|
|
|
|
2010-11-04 13:28:09 +08:00
|
|
|
#include <typeinfo>
|
|
|
|
|
|
|
|
// CHECK: @_ZTIDn = external constant i8*
|
2009-09-15 12:39:46 +08:00
|
|
|
int* a = nullptr;
|
|
|
|
|
|
|
|
void f() {
|
|
|
|
int* a = nullptr;
|
|
|
|
}
|
2010-03-08 07:24:59 +08:00
|
|
|
|
|
|
|
typedef decltype(nullptr) nullptr_t;
|
|
|
|
|
|
|
|
nullptr_t get_nullptr();
|
|
|
|
|
|
|
|
struct X { };
|
|
|
|
void g() {
|
|
|
|
// CHECK: call i8* @_Z11get_nullptrv()
|
|
|
|
int (X::*pmf)(int) = get_nullptr();
|
|
|
|
}
|
2010-11-04 13:28:09 +08:00
|
|
|
|
|
|
|
const std::type_info& f2() {
|
|
|
|
return typeid(nullptr_t);
|
2010-12-21 10:36:58 +08:00
|
|
|
}
|
2019-06-15 01:46:38 +08:00
|
|
|
|
|
|
|
union U {
|
|
|
|
int n;
|
|
|
|
nullptr_t b;
|
|
|
|
};
|
|
|
|
// CHECK-LABEL: define {{.*}}pr23833_a
|
|
|
|
// CHECK: store
|
|
|
|
// CHECK: load
|
|
|
|
// CHECK-NOT: load
|
|
|
|
// CHECK: ret i1 false
|
2020-02-11 22:09:18 +08:00
|
|
|
bool pr23833_a(U &u) { return bool(u.b); }
|
2019-06-15 01:46:38 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: define {{.*}}pr23833_b
|
|
|
|
// CHECK: store
|
|
|
|
// CHECK: load
|
|
|
|
// CHECK-NOT: load
|
|
|
|
// CHECK: ret i8* null
|
|
|
|
nullptr_t pr23833_b(nullptr_t &n) { return n; }
|
|
|
|
|
|
|
|
struct X1 { operator int*(); };
|
|
|
|
struct X2 { operator const nullptr_t&(); };
|
|
|
|
|
|
|
|
// CHECK-LABEL: define {{.*}}pr23833_c
|
|
|
|
// CHECK: call {{.*}}X1
|
|
|
|
// CHECK: call {{.*}}X2
|
|
|
|
// CHECK-NOT: load
|
|
|
|
// CHECK: ret i32
|
|
|
|
int pr23833_c() {
|
|
|
|
return X1() != X2();
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define {{.*}}pr23833_d
|
|
|
|
// CHECK: call {{.*}}X2
|
|
|
|
// CHECK-NOT: load
|
|
|
|
// CHECK: store
|
|
|
|
// CHECK: load
|
|
|
|
// CHECK: ret i32*
|
|
|
|
int *pr23833_d() {
|
|
|
|
int *p = X2();
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace PR39528 {
|
|
|
|
constexpr nullptr_t null = nullptr;
|
|
|
|
void f(nullptr_t);
|
|
|
|
void g() { f(null); }
|
|
|
|
}
|