summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/nullptr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-13 23:31:04 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-13 23:31:04 +0000
commit0476d069e394fec587858985ddee870360aec1ee (patch)
tree49febc5aec69871d253b5bd5daf92db6ca8e6ce2 /clang/test/CodeGenCXX/nullptr.cpp
parentb1027a480ac3d0545681e06b94012c95413b2116 (diff)
downloadbcm5719-llvm-0476d069e394fec587858985ddee870360aec1ee.tar.gz
bcm5719-llvm-0476d069e394fec587858985ddee870360aec1ee.zip
PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of type
nullptr_t does not access memory. We now reuse CK_NullToPointer to represent a conversion from a glvalue of type nullptr_t to a prvalue of nullptr_t where necessary. This reinstates r345562, reverted in r346065, now that CodeGen's handling of non-odr-used variables has been fixed. llvm-svn: 363337
Diffstat (limited to 'clang/test/CodeGenCXX/nullptr.cpp')
-rw-r--r--clang/test/CodeGenCXX/nullptr.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/nullptr.cpp b/clang/test/CodeGenCXX/nullptr.cpp
index e93f7061bdd..823c0d7d18a 100644
--- a/clang/test/CodeGenCXX/nullptr.cpp
+++ b/clang/test/CodeGenCXX/nullptr.cpp
@@ -22,3 +22,50 @@ void g() {
const std::type_info& f2() {
return typeid(nullptr_t);
}
+
+union U {
+ int n;
+ nullptr_t b;
+};
+// CHECK-LABEL: define {{.*}}pr23833_a
+// CHECK: store
+// CHECK: load
+// CHECK-NOT: load
+// CHECK: ret i1 false
+bool pr23833_a(U &u) { return u.b; }
+
+// 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); }
+}
OpenPOWER on IntegriCloud