aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-10-30 02:02:49 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-10-30 02:02:49 +0000
commitd2e69dfddbed3dccc7926cdf01e6aa32f47a0570 (patch)
tree19f42d86224a092777aab4fb1f18186668d7f54f /clang/lib/Sema/SemaInit.cpp
parent2f3e8b3d2e4c8679d891568ddc7b6fc73d19c4aa (diff)
downloadllvm-d2e69dfddbed3dccc7926cdf01e6aa32f47a0570.zip
llvm-d2e69dfddbed3dccc7926cdf01e6aa32f47a0570.tar.gz
llvm-d2e69dfddbed3dccc7926cdf01e6aa32f47a0570.tar.bz2
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. llvm-svn: 345562
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 29119a7..0bf2578 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -7644,9 +7644,13 @@ 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;
}