summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.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/SemaExpr.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/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7b3590aeb1a..9b1e362c262 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -635,8 +635,10 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
if (E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
Cleanup.setExprNeedsCleanups(true);
- Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E, nullptr,
- VK_RValue);
+ // C++ [conv.lval]p3:
+ // If T is cv std::nullptr_t, the result is a null pointer constant.
+ CastKind CK = T->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue;
+ Res = ImplicitCastExpr::Create(Context, T, CK, E, nullptr, VK_RValue);
// C11 6.3.2.1p2:
// ... if the lvalue has atomic type, the value has the non-atomic version
OpenPOWER on IntegriCloud