summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-14 17:46:38 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-14 17:46:38 +0000
commit27252a1f9546ba379b76176d6f6707a1ae8d05cd (patch)
tree154bfc319ec7f544da295c4863cb9cb16807c7e1 /clang/lib/Sema/SemaInit.cpp
parent24cdcadcc5e875b05bbb70eb123ea4f0a018ee83 (diff)
downloadbcm5719-llvm-27252a1f9546ba379b76176d6f6707a1ae8d05cd.tar.gz
bcm5719-llvm-27252a1f9546ba379b76176d6f6707a1ae8d05cd.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 r363337, reverted in r363352. llvm-svn: 363429
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 1a1d9347985..1301de4b111 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -7779,9 +7779,13 @@ ExprResult InitializationSequence::Perform(Sema &S,
case SK_LValueToRValue: {
assert(CurInit.get()->isGLValue() && "cannot load from a prvalue");
- CurInit = ImplicitCastExpr::Create(S.Context, Step->Type,
- CK_LValueToRValue, CurInit.get(),
- /*BasePath=*/nullptr, VK_RValue);
+ // C++ [conv.lval]p3:
+ // If T is cv std::nullptr_t, the result is a null pointer constant.
+ CastKind CK =
+ Step->Type->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue;
+ CurInit =
+ ImplicitCastExpr::Create(S.Context, Step->Type, CK, CurInit.get(),
+ /*BasePath=*/nullptr, VK_RValue);
break;
}
OpenPOWER on IntegriCloud